Jump to content

User:Razzi/learning storage on vagrant

From Wikitech

vagrant init debian/buster64

vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
├─sda2   8:2    0    1K  0 part
└─sda5   8:5    0 1021M  0 part [SWAP]

Let's remove the swap

vagrant@buster:~$ sudo swapoff /dev/sda5
vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
├─sda2   8:2    0    1K  0 part
└─sda5   8:5    0 1021M  0 part

Now does it go away persistently?

vagrant@buster:~$ sudo mount
...

vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
├─sda2   8:2    0    1K  0 part
└─sda5   8:5    0 1021M  0 part

Looks like it went away, but then rebooting makes it come back.

Apparently mount -a is how to apply /etc/fstab:

vagrant@buster:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/vda1 during installation
UUID=983742b1-65a8-49d1-a148-a3865ea09e24 /               ext4    errors=remount-ro 0       1
# swap was on /dev/vda5 during installation
UUID=04559374-06db-46f1-aa31-e7a4e6ec3286 none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

But swap doesn't come back even when doing this.

vagrant@buster:~$ sudo mount -a
vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
├─sda2   8:2    0    1K  0 part
└─sda5   8:5    0 1021M  0 part

Can do this in verbose mode:

vagrant@buster:~$ sudo mount -av
/                        : ignored
none                     : ignored
/media/cdrom0            : ignored

Ok, so nothing happened. That second line is the key: nothing to mount, I guess. Swapon has an option for this


      swapon, swapoff - enable/disable devices and files for paging and swapping
SYNOPSIS
      swapon [options] [specialfile...]
      swapoff [-va] [specialfile...]
OPTIONS
      -a, --all
             All devices marked as ``swap in /etc/fstab are made available, except for those with  the  ``noauto  option.
             Devices that are already being used as swap are silently skipped.
vagrant@buster:~$ sudo swapon -a
vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
├─sda2   8:2    0    1K  0 part
└─sda5   8:5    0 1021M  0 part [SWAP]

Let's take it a step further and remove the swap partition entirely.

Doing some searching, I see how to do this with fdisk... I'm reluctant since it's interactive but I might as well get used to it.

sudo fdisk /dev/sda5

Seems promising, but perhaps I want to edit /dev/sda to remove sda5.

vagrant@buster:~$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.33.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: 19.8 GiB, 21265121280 bytes, 41533440 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0xfcf48969

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 39438335 39436288 18.8G 83 Linux
/dev/sda2       39440382 41531391  2091010 1021M  5 Extended
/dev/sda5       39440384 41531391  2091008 1021M 82 Linux swap / Solaris

Command (m for help): d
Partition number (1,2,5, default 5): 5

Partition 5 has been deleted.

Command (m for help): p
Disk /dev/sda: 19.8 GiB, 21265121280 bytes, 41533440 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0xfcf48969

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 39438335 39436288 18.8G 83 Linux
/dev/sda2       39440382 41531391  2091010 1021M  5 Extended

Command (m for help): w
The partition table has been altered.
Syncing disks.

vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
├─sda1   8:1    0 18.8G  0 part /
└─sda2   8:2    0    1K  0 part

Ok, so that worked, but /etc/fstab still has the old partition and uuid.

https://www.cyberciti.biz/faq/linux-how-to-delete-a-partition-with-fdisk-command/


https://www.xmodulo.com/how-to-run-fdisk-in-non-interactive-batch-mode.html

Ok, I removed the sda2 part and now want to see if I can make sda1 take up the whole disk.

Ah, that was cdrom.

Ok, so it turns out that to resize the / partition I can delete it and recreate it with the full disk size. Nothing happened until I rebooted. Maybe that's a benefit of logical volumes: doing this stuff online?

https://askubuntu.com/questions/24027/how-can-i-resize-an-ext-root-partition-at-runtime

vagrant@buster:~$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 19.8G  0 disk
└─sda1   8:1    0 19.8G  0 part /

Now let's make a volume group. 2 options: put root on this volume group, or partition the disk then put half on a volume group.