Ubuntu 18.04扩展磁盘容量到单独分区

vmvare下

扩展原有磁盘容量时,一般情况下需要删除分区重新划分,这样就删除了原有的数据,为了保留原有数据,把扩展的分区额外划分到一个分区,自动挂载到一个目录,减少风险。

原来只有50G容量,扩展成200G,增加的150G单独做成一个分区。

Ubuntu 18.04扩展磁盘容量到单独分区_第1张图片

 

Linux下

logread@logread:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        49G   35G   12G  75% /
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 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: 79FFB5A5-7F6B-47AD-A0C9-A017D9011EA0

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 104855551 104851456  50G Linux filesystem

fdisk增加分区

logread@logread:~$ sudo fdisk /dev/sda
[sudo] password for logread: 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p

Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 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: 79FFB5A5-7F6B-47AD-A0C9-A017D9011EA0

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 104855551 104851456  50G Linux filesystem

Command (m for help): n
Partition number (3-128, default 3): 3
First sector (104855552-419430366, default 104855552): 
Last sector, +sectors or +size{K,M,G,T,P} (104855552-419430366, default 419430366): 

Created a new partition 3 of type 'Linux filesystem' and of size 150 GiB.

Command (m for help): p
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 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: 79FFB5A5-7F6B-47AD-A0C9-A017D9011EA0

Device         Start       End   Sectors  Size Type
/dev/sda1       2048      4095      2048    1M BIOS boot
/dev/sda2       4096 104855551 104851456   50G Linux filesystem
/dev/sda3  104855552 419430366 314574815  150G Linux filesystem

Command (m for help): w
GPT PMBR size mismatch (104857599 != 419430399) will be corrected by w(rite).

The partition table has been altered.
Syncing disks.

mkfs.ext4格式化

logread@logread:~$ sudo mkfs.ext4 /dev/sda3 
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 39321600 4k blocks and 9849600 inodes
Filesystem UUID: cf0f2a70-b399-4486-a287-3cb6f6b1baac
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

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

mount挂载

logread@logread:~$ sudo mount -t ext4 /dev/sda3  yubo.wang/
/dev/sda3 on /home/logread/yubo.wang type ext4 (rw,relatime,data=ordered)

logread@logread:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       147G   61M  140G   1% /home/logread/yubo.wang

自动挂载

/etc/fstab

UUID=cf0f2a70-b399-4486-a287-3cb6f6b1baac /home/logread/yubo.wang ext4 defaults 0 0

 

你可能感兴趣的:(TOOLS)