piektdiena, 2017. gada 6. janvāris

Ubuntu server extend disk partition in ssh without LiveCD

How to extend partition in Ubuntu from terminal without gparted and livecd

My vm disk was full. Kind VM adminstrator extended disk. How can you extend partition.
In Windows 2012 it is easy on the fly operation. In Ubuntu server they (google advisers) offer to boot LiveCD and run GParted. What if boot from CD is not an option? I have only ssh access. Well
(parted) print list
Shows volume already is extended but you have to create and format partition and then mount it somewhere.
Model: ATA VMware Virtual I (scsi)
Disk /dev/sda: 129GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   129GB   129GB   extended
 5      257MB   21.0GB  20.7GB  logical                lvm

  • Extend logical partition

$ mkpart logical ext3 21.1GB 129GB

Check that new partition appears in list
Type parted and then type print all

 (parted) print all
Model: ATA VMware Virtual I (scsi)
Disk /dev/sda: 129GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   129GB   129GB   extended
 5      257MB   21.0GB  20.7GB  logical                lvm
 6      21.0GB  129GB   108GB   logical

As you can notice partition is numbered automatically sda6

  • Format partiton

$ mkfs.ext4 /dev/sda6

  • Mount somewhere
Mount in empty directory or separate partition. I want it in empty directory, so

$ mount /dev/sda6 /var/data

  • Make  changes permanent  

$ echo "/dev/sda6 /var/data ext4 defaults 0 0" | sudo tee -a /etc/fstab

  • Restart the system

$ shutdown -r now

Nav komentāru:

Ierakstīt komentāru