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

vmvare下

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

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

 

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

自动挂载

logread@logread:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Mar 15 09:24 cf0f2a70-b399-4486-a287-3cb6f6b1baac -> ../../sda3

/etc/fstab

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

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值