Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize DigitalOcean droplet mounted volume #382

Open
coding-to-music opened this issue Jun 9, 2022 · 1 comment
Open

Resize DigitalOcean droplet mounted volume #382

coding-to-music opened this issue Jun 9, 2022 · 1 comment

Comments

@coding-to-music
Copy link
Owner

coding-to-music commented Jun 9, 2022

sudo parted

Output

GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)                                                                  
(parted) help                                                             
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a
        particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print                                                            
Model: DO Volume (scsi)
Disk /dev/sda: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  215GB  215GB  xfs

(parted) quit                                                             
sudo parted

Output

GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resize 1                                                         
Error: The resize command has been removed in parted 3.0
(parted) resizepart 1                                                     
Warning: Partition /dev/sda is being used. Are you sure you want to continue?
Yes/No? yes                                                               
End?  [215GB]?                                                            
(parted) quit                                                             
Information: You may need to update /etc/fstab.
sudo resize2fs /dev/vda1         

Output

resize2fs 1.45.5 (07-Jan-2020)
The filesystem is already 20943099 (4k) blocks long.  Nothing to do!
@coding-to-music
Copy link
Owner Author

coding-to-music commented Jun 9, 2022

Expand XFS filesystems

For unpartitioned volumes using the XFS filesystem, pass the mount point to the xfs_growfs tool:

sudo xfs_growfs /mnt/your_mount_point

The output will look like this:

meta-data=/dev/sda               isize=512    agcount=4, agsize=32768000 blks
        =                       sectsz=512   attr=2, projid32bit=1
        =                       crc=1        finobt=1 spinodes=0
data     =                       bsize=4096   blocks=131072000, imaxpct=25
        =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=64000, version=2
        =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 131072000 to 157286400
lsblk

Output

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0     7:0    0     4K  1 loop /snap/bare/5
loop1     7:1    0 131.9M  1 loop /snap/chromium/2000
loop2     7:2    0  55.5M  1 loop /snap/core18/2409
loop3     7:3    0 113.9M  1 loop /snap/core/13308
loop4     7:4    0  61.9M  1 loop /snap/core20/1518
loop5     7:5    0  54.6M  1 loop /snap/doctl/938
loop6     7:6    0 164.8M  1 loop /snap/gnome-3-28-1804/161
loop7     7:7    0  70.4M  1 loop /snap/core22/188
loop8     7:8    0    37M  1 loop /snap/gh/502
loop9     7:9    0  67.8M  1 loop /snap/lxd/22753
loop10    7:10   0 168.1M  1 loop /snap/postman/149
loop11    7:11   0  81.3M  1 loop /snap/gtk-common-themes/1534
loop12    7:12   0 254.1M  1 loop /snap/gnome-3-38-2004/106
loop13    7:13   0  36.2M  1 loop /snap/heroku/4092
loop14    7:14   0   4.2M  1 loop /snap/tree/18
loop15    7:15   0  11.8M  1 loop /snap/nmap/2650
loop16    7:16   0    47M  1 loop /snap/snapd/16010
sda       8:0    0   200G  0 disk /mnt/volume_nyc1_01
vda     252:0    0    80G  0 disk
├─vda1  252:1    0  79.9G  0 part /
├─vda14 252:14   0     4M  0 part
└─vda15 252:15   0   106M  0 part /boot/efi
df -h

Output

Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           394M  1.3M  392M   1% /run
/dev/vda1        78G   59G   19G  76% /
tmpfs           2.0G   16K  2.0G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop0      128K  128K     0 100% /snap/bare/5
/dev/loop2       56M   56M     0 100% /snap/core18/2409
/dev/loop1      132M  132M     0 100% /snap/chromium/2000
/dev/loop3      114M  114M     0 100% /snap/core/13308
/dev/loop4       62M   62M     0 100% /snap/core20/1518
/dev/sda        100G  100G   28K 100% /mnt/volume_nyc1_01
/dev/loop5       55M   55M     0 100% /snap/doctl/938
/dev/vda15      105M  5.2M  100M   5% /boot/efi
/dev/loop7       71M   71M     0 100% /snap/core22/188
/dev/loop6      165M  165M     0 100% /snap/gnome-3-28-1804/161
/dev/loop9       68M   68M     0 100% /snap/lxd/22753
/dev/loop8       37M   37M     0 100% /snap/gh/502
/dev/loop10     169M  169M     0 100% /snap/postman/149
/dev/loop11      82M   82M     0 100% /snap/gtk-common-themes/1534
/dev/loop12     255M  255M     0 100% /snap/gnome-3-38-2004/106
/dev/loop13      37M   37M     0 100% /snap/heroku/4092
/dev/loop14     4.3M  4.3M     0 100% /snap/tree/18
/dev/loop15      12M   12M     0 100% /snap/nmap/2650
/dev/loop16      47M   47M     0 100% /snap/snapd/16010
sudo lsblk --fs

Output

NAME    FSTYPE   LABEL           UUID                                 FSAVAIL FSUSE% MOUNTPOINT
loop0   squashfs                                                            0   100% /snap/bare/5
loop1   squashfs                                                            0   100% /snap/chromium/2000
loop2   squashfs                                                            0   100% /snap/core18/2409
loop3   squashfs                                                            0   100% /snap/core/13308
loop4   squashfs                                                            0   100% /snap/core20/1518
loop5   squashfs                                                            0   100% /snap/doctl/938
loop6   squashfs                                                            0   100% /snap/gnome-3-28-1804/161
loop7   squashfs                                                            0   100% /snap/core22/188
loop8   squashfs                                                            0   100% /snap/gh/502
loop9   squashfs                                                            0   100% /snap/lxd/22753
loop10  squashfs                                                            0   100% /snap/postman/149
loop11  squashfs                                                            0   100% /snap/gtk-common-themes/1534
loop12  squashfs                                                            0   100% /snap/gnome-3-38-2004/106
loop13  squashfs                                                            0   100% /snap/heroku/4092
loop14  squashfs                                                            0   100% /snap/tree/18
loop15  squashfs                                                            0   100% /snap/nmap/2650
loop16  squashfs                                                            0   100% /snap/snapd/16010
sda     xfs                      a3281493-867b-4ad1-97c9-3f5ce7ff7517     28K   100% /mnt/volume_nyc1_01
vda
├─vda1  ext4     cloudimg-rootfs e17a595e-18f3-45e3-8f22-e0d1005fbae1   18.7G    76% /
├─vda14
└─vda15 vfat     UEFI            639E-09CF                              99.2M     5% /boot/efi

Expand ext4 filesystems

For unpartitioned volumes using the ext4 filesystem, pass the /dev/disk/by-id volume identifier to resize2fs:

sudo resize2fs /dev/disk/by-id/scsi-0DO_example

The output will look like this:

resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/disk/by-id/scsi-0DO_example is mounted on /mnt/volume-example; on-line resizing required
old_desc_blocks = 25, new_desc_blocks = 32
The filesystem on /dev/disk/by-id/scsi-0DO_example is now 131072000 (4k) blocks long.

Note

If you receive the error open: No such file or directory while opening /dev/disk/by-id/scsi-0DO_example, ensure the volume is mounted and then retry the command.

Verify that the larger filesystem is available with df:

df -h -x tmpfs -x devtmpfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G  1.1G   18G   6% /
/dev/sda        197G   60M  187G   1% /mnt/volume-nyc1-01

Depending on the Droplet’s operating system, you may also need to reboot to see the volume’s new size.

meta-data=/dev/sda               isize=512    agcount=4, agsize=6553600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=26214400, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 26214400 to 52428800
lsblk

Output

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0     7:0    0     4K  1 loop /snap/bare/5
loop1     7:1    0 131.9M  1 loop /snap/chromium/2000
loop2     7:2    0  55.5M  1 loop /snap/core18/2409
loop3     7:3    0 113.9M  1 loop /snap/core/13308
loop4     7:4    0  61.9M  1 loop /snap/core20/1518
loop5     7:5    0  54.6M  1 loop /snap/doctl/938
loop6     7:6    0 164.8M  1 loop /snap/gnome-3-28-1804/161
loop7     7:7    0  70.4M  1 loop /snap/core22/188
loop8     7:8    0    37M  1 loop /snap/gh/502
loop9     7:9    0  67.8M  1 loop /snap/lxd/22753
loop10    7:10   0 168.1M  1 loop /snap/postman/149
loop11    7:11   0  81.3M  1 loop /snap/gtk-common-themes/1534
loop12    7:12   0 254.1M  1 loop /snap/gnome-3-38-2004/106
loop13    7:13   0  36.2M  1 loop /snap/heroku/4092
loop14    7:14   0   4.2M  1 loop /snap/tree/18
loop15    7:15   0  11.8M  1 loop /snap/nmap/2650
loop16    7:16   0    47M  1 loop /snap/snapd/16010
sda       8:0    0   200G  0 disk /mnt/volume_nyc1_01
vda     252:0    0    80G  0 disk
├─vda1  252:1    0  79.9G  0 part /
├─vda14 252:14   0     4M  0 part
└─vda15 252:15   0   106M  0 part /boot/efi
df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           394M  1.3M  392M   1% /run
/dev/vda1        78G   59G   19G  76% /
tmpfs           2.0G   16K  2.0G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop0      128K  128K     0 100% /snap/bare/5
/dev/loop2       56M   56M     0 100% /snap/core18/2409
/dev/loop1      132M  132M     0 100% /snap/chromium/2000
/dev/loop3      114M  114M     0 100% /snap/core/13308
/dev/loop4       62M   62M     0 100% /snap/core20/1518
/dev/sda        200G  101G  100G  51% /mnt/volume_nyc1_01
/dev/loop5       55M   55M     0 100% /snap/doctl/938
/dev/vda15      105M  5.2M  100M   5% /boot/efi
/dev/loop7       71M   71M     0 100% /snap/core22/188
/dev/loop6      165M  165M     0 100% /snap/gnome-3-28-1804/161
/dev/loop9       68M   68M     0 100% /snap/lxd/22753
/dev/loop8       37M   37M     0 100% /snap/gh/502
/dev/loop10     169M  169M     0 100% /snap/postman/149
/dev/loop11      82M   82M     0 100% /snap/gtk-common-themes/1534
/dev/loop12     255M  255M     0 100% /snap/gnome-3-38-2004/106
/dev/loop13      37M   37M     0 100% /snap/heroku/4092
/dev/loop14     4.3M  4.3M     0 100% /snap/tree/18
/dev/loop15      12M   12M     0 100% /snap/nmap/2650
/dev/loop16      47M   47M     0 100% /snap/snapd/16010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant