挂载磁盘到分区

查看磁盘信息 fdisk -l

Disk /dev/loop0: 88.5 MiB, 92778496 bytes, 181208 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 89 MiB, 93327360 bytes, 182280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 97CCCB85-2D24-428E-BA02-DE83C4E56EC3

Device       Start       End   Sectors   Size Type
/dev/sda1     2048      4095      2048     1M BIOS boot
/dev/sda2     4096   2101247   2097152     1G Linux filesystem
/dev/sda3  2101248 976771071 974669824 464.8G Linux filesystem


Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

找到未挂载的硬盘 /dev/sdb

格式化分区(未挂载的磁盘)

mkfs -t ext4 /dev/sdb

得到如下正常

mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 244190646 4k blocks and 61054976 inodes
Filesystem UUID: xxxxxxxxx
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

如果原来的 /home 有数据可以拷贝到别的地方备份
修改分区配置文件:

sudo vi /etc/fstab

如果之前的/home配置如下:
`#UUID=b667eb6a-0deb-4373-b6d1-c906f2c70f74 /home ext4 defaults 0 2

`
需要注释掉
在后面添加 挂载地址

 /dev/sdb /home ext4 defaults 0 2

重新机器即可

df -h  

查看 /home是否被挂载

Filesystem                         Size  Used Avail Use% Mounted on
udev                                16G     0   16G   0% /dev
tmpfs                              3.2G  1.5M  3.2G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.9G  2.3G  1.5G  62% /
tmpfs                               16G     0   16G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               16G     0   16G   0% /sys/fs/cgroup
/dev/loop1                          89M   89M     0 100% /snap/core/7270
/dev/loop0                          90M   90M     0 100% /snap/core/7713
/dev/sda2                          976M   76M  834M   9% /boot
/dev/sdb                           916G  1.5G  868G   1% /home
tmpfs                              3.2G     0  3.2G   0% /run/user/0

tap 补齐命令时error:
cannot create temp file for here-document: No space left on device
#df -h查看


Filesystem                         Size  Used Avail Use% Mounted on
udev                                16G     0   16G   0% /dev
tmpfs                              3.2G  1.6M  3.2G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.9G  3.9G     0 100% /
tmpfs                               16G     0   16G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               16G     0   16G   0% /sys/fs/cgroup
/dev/loop1                          89M   89M     0 100% /snap/core/7270
/dev/loop0                          90M   90M     0 100% /snap/core/7713
/dev/sda2                          976M   76M  834M   9% /boot
/dev/sdb                           916G  4.5G  865G   1% /home
tmpfs                              3.2G     0  3.2G   0% /run/user/0

/dev/mapper/ubuntu–vg-ubuntu–lv 这个已经100%了

sudo vgdisplay

看到

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <464.76 GiB
  PE Size               4.00 MiB
  Total PE              118978
  Alloc PE / Size       1024 / 4.00 GiB
  Free  PE / Size       117954 / <460.76 GiB
  VG UUID               3nu7QJ-oKyc-EjrC-sw2D-khfy-pvAe-mWMUGL

Alloc PE / Size 1024 / 4.00 GiB
Free PE / Size 117954 / <460.76 GiB #還沒有分配
下面就將這沒有分配的460G擴容給它
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

得到

Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to <464.76 GiB (118978 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

再查看df -h 已经挂载进来了

Filesystem                         Size  Used Avail Use% Mounted on
udev                                16G     0   16G   0% /dev
tmpfs                              3.2G  1.6M  3.2G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  458G  3.9G  435G   1% /
tmpfs                               16G     0   16G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               16G     0   16G   0% /sys/fs/cgroup
/dev/loop1                          89M   89M     0 100% /snap/core/7270
/dev/loop0                          90M   90M     0 100% /snap/core/7713
/dev/sda2                          976M   76M  834M   9% /boot
/dev/sdb                           916G  4.5G  865G   1% /home
tmpfs                              3.2G     0  3.2G   0% /run/user/0

sudo vgdisplay查看

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <464.76 GiB
  PE Size               4.00 MiB
  Total PE              118978
  Alloc PE / Size       118978 / <464.76 GiB
  Free  PE / Size       0 / 0   
  VG UUID               3nu7QJ-oKyc-EjrC-sw2D-khfy-pvAe-mWMUGL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值