Skip to content

hd partitions mounts

Martin Vanbrabant edited this page Jan 17, 2019 · 1 revision

Harddisk partitions and mounts

Important note

Info in this page applies to the servers tcblsso and tcblsso2, NOT tcblsso3! tcblsso3 has a disk large enough to contain the OS and the data.

Intro

Due to extension of disk capacity, there is a non-standard partition layout. We started from a disk with capacity of ± 39GB that was later extended with an extra 216GB.

Here we document how to go from this situation to a situation where the rest of the disk space is mounted to a folder /srv/opt. All commands described here are run with root permissions.

Partitioning

1 Start cfdisk on /dev/sda, since this is the device holding the extra space.

cfdisk /dev/sda

The layout looks like this:

                                         Disk: /dev/sda
                      Size: 256 GiB, 274877906944 bytes, 536870912 sectors
                               Label: dos, identifier: 0x6b48698f

    Device         Boot         Start         End     Sectors    Size   Id Type
>>  /dev/sda1      *             2048    81788927    81786880     39G   83 Linux                 
    /dev/sda2                81790974    83884031     2093058   1022M    5 Extended
    └─/dev/sda5              81790976    83884031     2093056   1022M   82 Linux swap / Solar
    Free space               83884032   536870911   452986880    216G








 ┌─────────────────────────────────────────────────────────────────────────────────────────────┐
 │ Partition type: Linux (83)                                                                  │
 │     Attributes: 80                                                                          │
 │     Filesystem: ext4                                                                        │
 │Filesystem UUID: f7af2c0e-a090-468c-9378-16346e59d515                                        │
 │     Mountpoint: / (mounted)                                                                 │
 └─────────────────────────────────────────────────────────────────────────────────────────────┘
       [Bootable]  [ Delete ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]

2 Create a new partition from Free space (select the free space and press [ New ]:

                                         Disk: /dev/sda
                      Size: 256 GiB, 274877906944 bytes, 536870912 sectors
                               Label: dos, identifier: 0x6b48698f

    Device         Boot         Start         End     Sectors    Size   Id Type
    /dev/sda1      *             2048    81788927    81786880     39G   83 Linux
    /dev/sda2                81790974    83884031     2093058   1022M    5 Extended
    └─/dev/sda5              81790976    83884031     2093056   1022M   82 Linux swap / Solar
>>  Free space               83884032   536870911   452986880    216G                            






                   [   New  ]  [  Quit  ]  [  Help  ]  [  Write ]  [  Dump  ]

3 Answer a few questions in the interface:

 Partition size: 216G
 Partition type: Linux (83)		(don't press enter!)

4 Now you get an overview of the new situation. Press [ Write ].

                                         Disk: /dev/sda
                      Size: 256 GiB, 274877906944 bytes, 536870912 sectors
                               Label: dos, identifier: 0x6b48698f

    Device         Boot         Start         End     Sectors    Size   Id Type
    /dev/sda1      *             2048    81788927    81786880     39G   83 Linux
    /dev/sda2                81790974    83884031     2093058   1022M    5 Extended
    └─/dev/sda5              81790976    83884031     2093056   1022M   82 Linux swap / Solar
>>  /dev/sda3                83884032   536870911   452986880    216G   83 Linux                 



 ┌─────────────────────────────────────────────────────────────────────────────────────────────┐
 │Partition type: Linux (83)                                                                   │
 └─────────────────────────────────────────────────────────────────────────────────────────────┘
       [Bootable]  [ Delete ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]


                     Write partition table to disk (this might destroy data)

Of course you are sure (type "yes"), in case this is asked. And also are you really really sure.

You should see a message at the bottom:

The partition table has been altered.

5 Now quit. You should see:

Syncing disks.

6 Reboot (in order to effectively be able to use the partition).

reboot

7 Format the partition:

mkfs.ext4 /dev/sda3

Output:

mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 56623104 4k blocks and 14183424 inodes
Filesystem UUID: ac8c386e-f0ee-43e8-9383-22ace68de7dd
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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Mounting

The new partition will be mounted on /srv (already in the directory tree).

1 Before being able to mount, we need the UUID of the new formatted partition. We can see this with cfdisk:

cfdisk /dev/sda

Select the last partition /dev/sda3 and the UUID appears at the bottom:

                                                 Disk: /dev/sda
                              Size: 256 GiB, 274877906944 bytes, 536870912 sectors
                                       Label: dos, identifier: 0x6b48698f

    Device           Boot            Start           End       Sectors      Size     Id Type
    /dev/sda1        *                2048      81788927      81786880       39G     83 Linux
    /dev/sda2                     81790974      83884031       2093058     1022M      5 Extended
    └─/dev/sda5                   81790976      83884031       2093056     1022M     82 Linux swap / Solaris
>>  /dev/sda3                     83884032     536870911     452986880      216G     83 Linux                   




 ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 │ Partition type: Linux (83)                                                                                 │
 │     Filesystem: ext4                                                                                       │
 │Filesystem UUID: ac8c386e-f0ee-43e8-9383-22ace68de7dd                                                       │
 └────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
               [Bootable]  [ Delete ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]

Copy the UUID value and then select Quit.

2 Open /etc/fstab in your favourite editor, so that it looks like this (last 2 lines are added; use the copied UUID value):

# /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/sda1 during installation
UUID=f7af2c0e-a090-468c-9378-16346e59d515 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=42432368-4968-4c4f-abb3-f0a0c6a0bce5 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
# new partition, added after installation
UUID=ac8c386e-f0ee-43e8-9383-22ace68de7dd /srv            ext4   errors=remount-ro  0       2

3 Mount the new partition:

mount /srv

On future reboots the partition will be mounted automatically.

Clone this wiki locally