<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jkeown</title>
    <description>The latest articles on DEV Community by jkeown (@jkeown).</description>
    <link>https://dev.to/jkeown</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3158904%2F389f633b-060a-44c4-a0b4-663cb3bc4cb7.png</url>
      <title>DEV Community: jkeown</title>
      <link>https://dev.to/jkeown</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jkeown"/>
    <language>en</language>
    <item>
      <title>To script, or not to script...</title>
      <dc:creator>jkeown</dc:creator>
      <pubDate>Tue, 20 May 2025 16:44:35 +0000</pubDate>
      <link>https://dev.to/jkeown/to-script-or-not-to-script-3cko</link>
      <guid>https://dev.to/jkeown/to-script-or-not-to-script-3cko</guid>
      <description>&lt;p&gt;I've learned that documentation is a huge part of an admin's daily routine. Most processes are documented—ranging from server configurations and network setups to software installations, user accounts, and troubleshooting procedures. I've even been told that as much as 70% of the job involves documentation.&lt;/p&gt;

&lt;p&gt;I've written this post to share a simple Linux command that I've found especially helpful for my own documentation and note-taking: the &lt;strong&gt;script&lt;/strong&gt; command.&lt;/p&gt;

&lt;p&gt;Here are the steps for using the script command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run the following command to start recording your session:&lt;br&gt;
script  record_session.txt (file name is up to you)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Begin working as usual. All input and output during the session will be saved to the file specified in step 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you're finished, type &lt;strong&gt;exit&lt;/strong&gt; or &lt;strong&gt;ctrl-d&lt;/strong&gt; to quit the script command.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point, I usually run &lt;strong&gt;cat&lt;/strong&gt; on the file to review its contents, then copy and paste it into a new document where I can add notes or additional context as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The created file may contain some binary or control characters, so if you open it with less or vi, you might see a lot of non-human-readable output.&lt;/p&gt;

&lt;p&gt;Using &lt;strong&gt;less -fr&lt;/strong&gt; will print the file clearly.&lt;/p&gt;

&lt;p&gt;Below is a brief terminal example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ script record_cli.txt
Script started, output log file is 'record_cli.txt'.

[sorad@dev9 ~]$ w
 12:34:10 up 5 days, 20:54,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
sorad    pts/0     11:30    2.00s  0.05s  0.00s script record_cli.txt

[sorad@dev9 ~]$ mkdir testy/testerson
mkdir: cannot create directory ‘testy/testerson’: No such file or directory

[sorad@dev9 ~]$ mkdir -pv testy/testerson
mkdir: created directory 'testy'
mkdir: created directory 'testy/testerson'

[sorad@dev9 ~]$ exit
exit
Script done.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;File contents of record_cli.txt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ cat record_cli.txt

Script started on 2025-05-20 12:33:56-04:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="80" LINES="24"]
[sorad@dev9 ~]$ w
 12:34:10 up 5 days, 20:54,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
sorad    pts/0     11:30    2.00s  0.05s  0.00s script record_cli.txt
[sorad@dev9 ~]$ mkdir testy/testerson
mkdir: cannot create directory ‘testy/testerson’: No such file or directory
[sorad@dev9 ~]$ mkdir -pv testy/testerson
mkdir: created directory 'testy'
mkdir: created directory 'testy/testerson'
[sorad@dev9 ~]$ exit
exit

Script done on 2025-05-20 12:34:52-04:00 [COMMAND_EXIT_CODE="0"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me know if you found this helpful. Thank you for reading.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>documentation</category>
      <category>produ</category>
    </item>
    <item>
      <title>LVM Land</title>
      <dc:creator>jkeown</dc:creator>
      <pubDate>Sun, 18 May 2025 19:24:54 +0000</pubDate>
      <link>https://dev.to/jkeown/lvm-land-14b7</link>
      <guid>https://dev.to/jkeown/lvm-land-14b7</guid>
      <description>&lt;p&gt;Related Series Links:&lt;br&gt;
1.&lt;a href="https://dev.to/jkeown/partition-party-4dpe"&gt;Partition Party&lt;/a&gt;&lt;br&gt;
2.&lt;a href="https://dev.to/jkeown/now-we-need-a-filesystem-then-mount-it-37le"&gt;Filesystem &amp;amp; mounting&lt;/a&gt;&lt;br&gt;
3.LVM Land (this article)&lt;/p&gt;

&lt;p&gt;This post will explore the more practical world of the Logical Volume  Manager.  It provides enhanced storage management by allowing dynamic allocation of storage space. It enables administrators to create, resize, and manage disk partitions more flexibly than traditional partitioning methods. Let's first check our block status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ lsblk -f /dev/{sdb,sdc}
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdb                                                                           
├─sdb1 xfs                e191547c-35b1-44f8-9278-8160eac6e300                
├─sdb2 ext4   1.0         3060ac82-ea5e-4cf3-b2f7-975154512ed3                
├─sdb3                                                                        
├─sdb4                                                                        
├─sdb5                                                                        
└─sdb6                                                                        
sdc                                                                           
├─sdc1 xfs                81bff549-814e-407f-ab1f-396cb95a7f09    1.4G    28% /mountsdc
├─sdc2                                                                        
├─sdc3                                                                        
├─sdc4                                                                        
├─sdc5                                                                        
└─sdc6 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have 9 of our 2 GB partitions available. I'll use that space for logical volumes. It's back into &lt;strong&gt;fdisk&lt;/strong&gt; to delete some partitions.  For brevity's sake, I'll only show the process for sdc. Take note that deleting partition 4 (extended) also deletes its logical partitions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk /dev/sdc

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): p

Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot    Start      End Sectors Size Id Type
/dev/sdc1           2048  4196351 4194304   2G 83 Linux
/dev/sdc2        4196352  8390655 4194304   2G 83 Linux
/dev/sdc3        8390656 12584959 4194304   2G 83 Linux
/dev/sdc4       12584960 20971519 8386560   4G  5 Extended
/dev/sdc5       12587008 16781311 4194304   2G 83 Linux
/dev/sdc6       16783360 20971519 4188160   2G 83 Linux

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

Partition 2 has been deleted.

Command (m for help): d
Partition number (1,3-6, default 6): 3

Partition 3 has been deleted.

Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot    Start      End Sectors Size Id Type
/dev/sdc1           2048  4196351 4194304   2G 83 Linux
/dev/sdc4       12584960 20971519 8386560   4G  5 Extended
/dev/sdc5       12587008 16781311 4194304   2G 83 Linux
/dev/sdc6       16783360 20971519 4188160   2G 83 Linux

Command (m for help): d
Partition number (1,4-6, default 6): 4

Partition 4 has been deleted.

Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot Start     End Sectors Size Id Type
/dev/sdc1        2048 4196351 4194304   2G 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reviewing the current block state again, we notice that the 9 unused partitions are no longer present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ lsblk -f /dev/{sdb,sdc}
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdb                                                                           
├─sdb1 xfs                e191547c-35b1-44f8-9278-8160eac6e300                
└─sdb2 ext4   1.0         3060ac82-ea5e-4cf3-b2f7-975154512ed3                
sdc                                                                           
└─sdc1 xfs                81bff549-814e-407f-ab1f-396cb95a7f09    1.4G    28% /mountsdc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Back into fdisk, I'll allocate the remaining space for each disk to a single partition. The default options will be selected to use all available disk space. I'll label the new partitions using code &lt;strong&gt;8e&lt;/strong&gt; so their type shows &lt;strong&gt;LVM&lt;/strong&gt;. Again, I'll only show the process for sdc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk /dev/sdc

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (2-4, default 2): 
First sector (4196352-20971519, default 4196352): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-20971519, default 20971519): 

Created a new partition 2 of type 'Linux' and of size 8 GiB.

Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot   Start      End  Sectors Size Id Type
/dev/sdc1          2048  4196351  4194304   2G 83 Linux
/dev/sdc2       4196352 20971519 16775168   8G 83 Linux

Command (m for help): t
Partition number (1,2, default 2): 
Hex code or alias (type L to list all): 8e

Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot   Start      End  Sectors Size Id Type
/dev/sdc1          2048  4196351  4194304   2G 83 Linux
/dev/sdc2       4196352 20971519 16775168   8G 8e Linux LVM

Command (m for help): w
The partition table has been altered.
Syncing disks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checking block status again, we see the single partitions added to each disk. sdb3 and sdc2 are ready for use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ lsblk -f /dev/{sdb,sdc}
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdb                                                                           
├─sdb1 xfs                e191547c-35b1-44f8-9278-8160eac6e300                
├─sdb2 ext4   1.0         3060ac82-ea5e-4cf3-b2f7-975154512ed3                
└─sdb3                                                                        
sdc                                                                           
├─sdc1 xfs                81bff549-814e-407f-ab1f-396cb95a7f09    1.4G    28% /mountsdc
└─sdc2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here comes the fun! The LVM structure consists of 3 layers: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Physical Volumes&lt;/strong&gt;: The partitions which make up the Volume Groups.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Volume Groups&lt;/strong&gt;: Combination of physical volumes creating one source of storage space.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logical Volumes&lt;/strong&gt;: Virtual/Logical partitions using the storage space available in its assigned volume group.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's check the current list of physical volumes using &lt;strong&gt;pvs&lt;/strong&gt;. We see there's only one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo pvs
[sudo] password for sorad: 
  PV         VG      Fmt  Attr PSize   PFree
  /dev/sda2  cs_vbox lvm2 a--  &amp;lt;19.00g    0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can add sdb3 and sdc2 to the physical volumes using &lt;strong&gt;pvcreate&lt;/strong&gt; specifying the partition to use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo pvcreate /dev/sdb3
  Physical volume "/dev/sdb3" successfully created.

[sorad@dev9 ~]$ sudo pvcreate /dev/sdc2
  Physical volume "/dev/sdc2" successfully created.

[sorad@dev9 ~]$ sudo pvs
  PV         VG      Fmt  Attr PSize   PFree 
  /dev/sda2  cs_vbox lvm2 a--  &amp;lt;19.00g     0 
  /dev/sdb3          lvm2 ---   &amp;lt;6.00g &amp;lt;6.00g
  /dev/sdc2          lvm2 ---   &amp;lt;8.00g &amp;lt;8.00g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's check the current Volume Groups with &lt;strong&gt;vgs&lt;/strong&gt;, then create a new VG using &lt;strong&gt;vgcreate&lt;/strong&gt;. The vgcreate syntax is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vgcreate Name_for_the_Group Partition_to_Use&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The PV and LV columns show the physical and logical volumes associated with each volume group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  cs_vbox   1   2   0 wz--n- &amp;lt;19.00g    0 

[sorad@dev9 ~]$ sudo vgcreate party_lv /dev/sdb3
  Volume group "party_lv" successfully created

[sorad@dev9 ~]$ sudo vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  cs_vbox    1   2   0 wz--n- &amp;lt;19.00g     0 
  party_lv   1   0   0 wz--n-  &amp;lt;6.00g &amp;lt;6.00g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to add sdc2 to the same volume group. Since the party_lv is already created, we need to use &lt;strong&gt;vgextend&lt;/strong&gt; to add more physical volumes.  The syntax is basically the same as vgcreate.  Just specify the name of the existing VG to use. Be sure to look at the changes in the PV, LV, VSize, and VFree columns after.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  cs_vbox    1   2   0 wz--n- &amp;lt;19.00g     0 
  party_lv   1   0   0 wz--n-  &amp;lt;6.00g &amp;lt;6.00g

[sorad@dev9 ~]$ sudo vgextend party_lv /dev/sdc2
  Volume group "party_lv" successfully extended

[sorad@dev9 ~]$ sudo vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  cs_vbox    1   2   0 wz--n- &amp;lt;19.00g     0 
  party_lv   2   0   0 wz--n-  13.99g 13.99g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Oops—I made a mistake in the naming convention. We're still working with volume groups, but I accidentally named the example party_&lt;strong&gt;lv&lt;/strong&gt;, which implies a logical volume. No problem—we can fix it using the &lt;strong&gt;vgrename&lt;/strong&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo vgrename party_lv party_vg
  Volume group "party_lv" successfully renamed to "party_vg"

[sorad@dev9 ~]$ sudo vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  cs_vbox    1   2   0 wz--n- &amp;lt;19.00g     0 
  party_vg   2   0   0 wz--n-  13.99g 13.99g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;strong&gt;lvs&lt;/strong&gt; next to show our current logical volumes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo lvs
  LV   VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root cs_vbox -wi-ao---- &amp;lt;17.00g                                                    
  swap cs_vbox -wi-ao----   2.00g  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You create logical volumes using &lt;strong&gt;lvcreate&lt;/strong&gt;.  For this example, I'll use the entire party_vg to create a single logical volume. However, you can allocate a smaller size if you'd like to repeat the process and create multiple logical volumes from party_vg. The lvcreate syntax is a bit more involved:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;lvcreate -n Name_for_Volume -L Size_to_Make_Volume Volume_Group_to_Use&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo lvcreate -n party_lv -L 13.99G party_vg
  Rounding up size to full physical extent 13.99 GiB
  Logical volume "party_lv" created.

[sorad@dev9 ~]$ sudo lvs
  LV       VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     cs_vbox  -wi-ao---- &amp;lt;17.00g                                                    
  swap     cs_vbox  -wi-ao----   2.00g                                                    
  party_lv party_vg -wi-a-----  13.99g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There we have it! The party_lv is now ready for the steps we're already familiar with, adding a filesystem and mounting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:  The path to logical volumes differs from that of physical partitions. While they still begin with /dev, logical volumes typically follow one of two path formats:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;/dev/mapper/vg_name-lv_name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/dev/vg_name/lv_name (symbolic link)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So for our example, either path will work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;/dev/mapper/party_vg-party_lv&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/dev/party_vg/party_lv&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the following you will see both used just to demonstrate.&lt;/p&gt;

&lt;p&gt;Add filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo mkfs.ext4 /dev/party_vg/party_lv
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 3667968 4k blocks and 917504 inodes
Filesystem UUID: dd2e3dcd-a2fb-4ae4-b102-505a966e6a71
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   

[sorad@dev9 ~]$ lsblk -f /dev/party_vg/party_lv 
NAME              FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
party_vg-party_lv ext4   1.0         dd2e3dcd-a2fb-4ae4-b102-505a966e6a71
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mounting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo mkdir /partition_party

[sorad@dev9 ~]$ sudo mount /dev/party_vg/party_lv /partition_party/

[sorad@dev9 ~]$ lsblk -f /dev/party_vg/party_lv 
NAME              FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
party_vg-party_lv ext4   1.0         dd2e3dcd-a2fb-4ae4-b102-505a966e6a71     13G     0% /partition_party
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I'll unmount the logical volume to demonstrate how to add it to the /etc/fstab file for persistent mounting. You can check the MOUNTPOINTS column (e.g., in the lsblk output) to see if and where the volume is currently mounted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo umount /partition_party/

[sorad@dev9 ~]$ lsblk -f /dev/party_vg/party_lv 
NAME              FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
party_vg-party_lv ext4   1.0         dd2e3dcd-a2fb-4ae4-b102-505a966e6a71

[sorad@dev9 ~]$ sudo vi /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the /etc/fstab file, I'm adding the primary path for the party_lv:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/dev/mapper/party_vg-party_lv /partition_party ext4 defaults 0 0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I run &lt;strong&gt;mount -a&lt;/strong&gt;, I get a reload message so I'll run that also, then display that our LV is mounted again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo mount -a
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

[sorad@dev9 ~]$ sudo systemctl daemon-reload

[sorad@dev9 ~]$ lsblk -f /dev/party_vg/party_lv 
NAME              FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
party_vg-party_lv ext4   1.0         dd2e3dcd-a2fb-4ae4-b102-505a966e6a71     13G     0% /partition_party
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To finish up and check the LV is operational, let's create a test file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo touch /partition_party/great_party.txt

[sorad@dev9 ~]$ ll /partition_party/
total 16
-rw-r--r--. 1 root root     0 May 16 14:39 great_party.txt
drwx------. 2 root root 16384 May 16 14:32 lost+found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope you've enjoyed this third journey with me in the storage realm. Questions, comments, and concerns are always welcome. Thank you again for reading.&lt;/p&gt;

&lt;p&gt;P.S.&lt;br&gt;
You may have noticed this warning in the beginning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This article was completed without unmounting any file systems. Please let me know if there's a specific reason to always unmount file systems first, as stated in the warning.&lt;/p&gt;

</description>
      <category>redhat</category>
      <category>admin</category>
      <category>storage</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Now, we need a filesystem. Then, mount it!</title>
      <dc:creator>jkeown</dc:creator>
      <pubDate>Wed, 14 May 2025 19:56:16 +0000</pubDate>
      <link>https://dev.to/jkeown/now-we-need-a-filesystem-then-mount-it-37le</link>
      <guid>https://dev.to/jkeown/now-we-need-a-filesystem-then-mount-it-37le</guid>
      <description>&lt;p&gt;Related Series Links:&lt;br&gt;
1.&lt;a href="https://dev.to/jkeown/partition-party-4dpe"&gt;Partition Party&lt;/a&gt;&lt;br&gt;
2.Filesystem &amp;amp; mounting (this article)&lt;br&gt;
3.&lt;a href="https://dev.to/jkeown/lvm-land-14b7"&gt;LVM Land&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a continuation of my Partition Party post. You may want to start there if you'd like to follow along.&lt;/p&gt;

&lt;p&gt;A few more steps are necessary before the disk is fully operational. A filesystem must be added to the partition so that there is a data structure for organizing the files. Then it must be mounted to a directory within the file system hierarchy.&lt;/p&gt;

&lt;p&gt;For brevity, I will mount just one of the partitions from the sdc drive. Let's review what we're working with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ lsblk /dev/sdc
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdc      8:32   0  10G  0 disk 
├─sdc1   8:33   0   2G  0 part 
├─sdc2   8:34   0   2G  0 part 
├─sdc3   8:35   0   2G  0 part 
├─sdc4   8:36   0   1K  0 part 
├─sdc5   8:37   0   2G  0 part 
└─sdc6   8:38   0   2G  0 part
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create the filesystem you use the &lt;strong&gt;mkfs&lt;/strong&gt; command to specify the type of filesystem followed by the path to the partition. In this example it will be XFS. Information regarding the new file structure is printed after creation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo mkfs.xfs /dev/sdc1
[sudo] password for sorad: 
meta-data=/dev/sdc1              isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see our new creation we can use &lt;strong&gt;blkid&lt;/strong&gt; or &lt;strong&gt;lsblk -f&lt;/strong&gt;. I prefer the latter as it also gives additional info and is more readable.  Let's use both actually. I'll also specify the sdc1 partition so we don't get the full list of all drives on the system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo blkid /dev/sdc1
/dev/sdc1: UUID="81bff549-814e-407f-ab1f-396cb95a7f09" TYPE="xfs" PARTUUID="5ace204b-01"

[sorad@dev9 ~]$ lsblk -f /dev/sdc1
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdc1 xfs                81bff549-814e-407f-ab1f-396cb95a7f09
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On to the mount step. First, create the directory that will be the mount point for the drive. Then mount the drive using the (you guessed it) &lt;strong&gt;mount&lt;/strong&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo mkdir /mountsdc

[sorad@dev9 ~]$ sudo mount /dev/sdc1 /mountsdc

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check the partition has been mounted we can use the &lt;strong&gt;df&lt;/strong&gt; command. &lt;strong&gt;lsblk -f&lt;/strong&gt; could be used also, as it includes the same info. The &lt;strong&gt;-hT&lt;/strong&gt; options specify to print sizes in human readable format and to show the Type of filesystem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ df -hT /dev/sdc1
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdc1      xfs   2.0G   47M  1.9G   3% /mountsdc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test if sdc1 is now fully operational, I will use &lt;strong&gt;fallocate&lt;/strong&gt;. This command is handy for whipping up a "fake" file, particularly of a large size.  I will not go into further detail in this article, but you will see in the command that the file is 500MB in size. Running &lt;strong&gt;df&lt;/strong&gt; again will show the available storage has dropped from 1.9G to 1.5G. Finally, I'll show the fake file in the mount point directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fallocate -l 500M /mountsdc/large_test_file
[sorad@dev9 ~]$ df -hT /dev/sdc1
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdc1      xfs   2.0G  547M  1.5G  28% /mountsdc
[sorad@dev9 ~]$ ll /mountsdc
total 512000
-rw-r--r--. 1 root root 524288000 May 14 13:26 large_test_file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I bet you thought we were finished. Not quite. The /etc/fstab file must be edited if the drive needs to be mounted automatically when the system starts. The following info needs to be provided in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;path to the partition&lt;/li&gt;
&lt;li&gt;mount point&lt;/li&gt;
&lt;li&gt;type of file system&lt;/li&gt;
&lt;li&gt;defaults 0 0 (Just add this for now - this will most often be used)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Time to open everyone's favorite editor, &lt;strong&gt;vi&lt;/strong&gt;! I've left out most of the file contents except for the newly added drive. The numbering above the data does &lt;strong&gt;NOT&lt;/strong&gt; go in the file.  It is only there to correlate to the checklist above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo vi /etc/fstab 
[sudo] password for sorad:

# /etc/fstab
# Created by anaconda on Tue Jan 14 19:45:24 2025
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
   1.       2.                       3.       4.
/dev/sdc1 /mountsdc                 xfs     defaults        0 0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The /etc/fstab file is quite particular as far as syntax goes. Additional characters, such as the numbering I included, can 'break' the file and cause your system to not boot properly. We can error check this file by running &lt;strong&gt;mount -a&lt;/strong&gt; which forces the system to remount all filesystems in fstab. If you can run this command without any errors, you should be good to go.&lt;/p&gt;

&lt;p&gt;A final note.  You can unmount a drive using &lt;strong&gt;umount&lt;/strong&gt;. Notice it is not &lt;strong&gt;un&lt;/strong&gt;mount. Easy to mix up!&lt;/p&gt;

&lt;p&gt;I welcome any questions, comments, or concerns. Thank you for reading.&lt;/p&gt;

</description>
      <category>redhat</category>
      <category>admin</category>
      <category>storgae</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Partition Party</title>
      <dc:creator>jkeown</dc:creator>
      <pubDate>Tue, 13 May 2025 23:12:05 +0000</pubDate>
      <link>https://dev.to/jkeown/partition-party-4dpe</link>
      <guid>https://dev.to/jkeown/partition-party-4dpe</guid>
      <description>&lt;p&gt;Related Series Links:&lt;br&gt;
1.Partition Party (this article)&lt;br&gt;
2.&lt;a href="https://dev.to/jkeown/now-we-need-a-filesystem-then-mount-it-37le"&gt;Filesystem &amp;amp; mounting&lt;/a&gt;&lt;br&gt;
3.&lt;a href="https://dev.to/jkeown/lvm-land-14b7"&gt;LVM Land&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The network team has just added two drives to one of the dev servers. It's time to have a partition party! I've ssh'd into the dev server. Let's take a look with &lt;strong&gt;lsblk&lt;/strong&gt;. The output shows two new 10 GB drives named sdb and sdc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ lsblk
NAME             MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda                8:0    0  20G  0 disk 
├─sda1             8:1    0   1G  0 part /boot
└─sda2             8:2    0  19G  0 part 
  ├─cs_vbox-root 253:0    0  17G  0 lvm  /
  └─cs_vbox-swap 253:1    0   2G  0 lvm  [SWAP]
sdb                8:16   0  10G  0 disk 
sdc                8:32   0  10G  0 disk 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also view this using &lt;strong&gt;fdisk -l&lt;/strong&gt; which will display the same info and a bit more. Let's try it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ fdisk -l
fdisk: cannot open /dev/sda: Permission denied
fdisk: cannot open /dev/sdb: Permission denied
fdisk: cannot open /dev/sdc: Permission denied
fdisk: cannot open /dev/mapper/cs_vbox-root: Permission denied
fdisk: cannot open /dev/mapper/cs_vbox-swap: Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Permission denied! Looks like elevated permissions are needed. Let's check if Sorad is in the wheel group.  Here's a couple of ways we can check. I know using &lt;strong&gt;id&lt;/strong&gt; is the simplest but &lt;strong&gt;grep&lt;/strong&gt; is fun.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sorad@dev9 ~]$ grep wheel /etc/group
wheel:x:10:sorad

[sorad@dev9 ~]$ groups
sorad wheel team1 hr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sorad is a sudoer so there's no need to switch users. Let's proceed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk -l
[sudo] password for sorad: 
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0xdde0aa1b

Device     Boot   Start      End  Sectors Size Id Type
/dev/sda1  *       2048  2099199  2097152   1G 83 Linux
/dev/sda2       2099200 41943039 39843840  19G 8e Linux LVM

Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b    

Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x3b6f1a7c  

Disk /dev/mapper/cs_vbox-root: 17 GiB, 18249416704 bytes, 35643392 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

Disk /dev/mapper/cs_vbox-swap: 2 GiB, 2147483648 bytes, 4194304 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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok, time to do some work. The &lt;strong&gt;fdisk&lt;/strong&gt; utility is used to create partitions. I'd like to point out that 'Changes will remain in memory only, until you decide to write them'. I've selected the fdisk option &lt;strong&gt;p&lt;/strong&gt; to display the current partition table which shows a blank slate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.37.4).
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/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next I use option &lt;strong&gt;n&lt;/strong&gt; to create a new partition. For the most part, I'll select the fdisk defaults as they are very helpful when selecting the partition and sector boundaries. I'll only need to specify the end of the sectors by specifying the amount of space the partition will have.  I'll create the first partition as 2 GB by entering &lt;strong&gt;+2G&lt;/strong&gt; for the 'Last sector' input. Using &lt;strong&gt;p&lt;/strong&gt; again, we'll see the new 2 GB partition on sdb.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): n
Partition type
p   primary (0 primary, 0 extended, 4 free)
e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +2G

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot Start     End Sectors Size Id Type
/dev/sdb1        2048 4196351 4194304   2G 83 Linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating the next two partitions involves the same process. Notice how fdisk keeps track of partitions and defaults.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): n
Partition type
p   primary (1 primary, 0 extended, 3 free)
e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (2-4, default 2): 
First sector (4196352-20971519, default 4196352): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-20971519, default 20971519): +2G

Created a new partition 2 of type 'Linux' and of size 2 GiB.

Command (m for help): n
Partition type
p   primary (2 primary, 0 extended, 2 free)
e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 
First sector (8390656-20971519, default 8390656): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (8390656-20971519, default 20971519): +2G

Created a new partition 3 of type 'Linux' and of size 2 GiB.

Command (m for help): 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it's time to create the fourth partition, fdisk intelligently defaults to an extended partition, allowing for future logical partitions. To best maximize the remaining disk space, all the default choices will be used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): n
Partition type
  p   primary (3 primary, 0 extended, 1 free)
  e   extended (container for logical partitions)
Select (default e): 

Using default response e.
Selected partition 4
First sector (12584960-20971519, default 12584960): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (12584960-20971519, default 20971519): 

Created a new partition 4 of type 'Extended' and of size 4 GiB.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot    Start      End Sectors Size Id Type
/dev/sdb1           2048  4196351 4194304   2G 83 Linux
/dev/sdb2        4196352  8390655 4194304   2G 83 Linux
/dev/sdb3        8390656 12584959 4194304   2G 83 Linux
/dev/sdb4       12584960 20971519 8386560   4G  5 Extended
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the fourth partition is extended, it is not recognized as being writable itself. We still have 4 GB of disk storage we can use. Let's continue with our 2 GB partitions.  Notice again how the fdisk defaults recognize that future partitions will be logical.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): n
All primary partitions are in use.
Adding logical partition 5
First sector (12587008-20971519, default 12587008): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (12587008-20971519, default 20971519): +2G

Created a new partition 5 of type 'Linux' and of size 2 GiB.

Command (m for help): n
All primary partitions are in use.
Adding logical partition 6
First sector (16783360-20971519, default 16783360): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (16783360-20971519, default 20971519): 

Created a new partition 6 of type 'Linux' and of size 2 GiB.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot    Start      End Sectors Size Id Type
/dev/sdb1           2048  4196351 4194304   2G 83 Linux
/dev/sdb2        4196352  8390655 4194304   2G 83 Linux
/dev/sdb3        8390656 12584959 4194304   2G 83 Linux
/dev/sdb4       12584960 20971519 8386560   4G  5 Extended
/dev/sdb5       12587008 16781311 4194304   2G 83 Linux
/dev/sdb6       16783360 20971519 4188160   2G 83 Linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just above, we see all the new partitions utilizing all of the disk.  What would happen if we try to create another partition?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): n
All primary partitions are in use.
Adding logical partition 7
No free sectors available.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the partitions are still in memory. Let's finalize the newly partitioned disk by writing it using &lt;strong&gt;w&lt;/strong&gt;. If this command is skipped the entire creation process will need to be repeated. Use &lt;strong&gt;lsblk&lt;/strong&gt; again to check our work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[sorad@dev9 ~]$ lsblk
NAME             MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda                8:0    0  20G  0 disk 
├─sda1             8:1    0   1G  0 part /boot
└─sda2             8:2    0  19G  0 part 
  ├─cs_vbox-root 253:0    0  17G  0 lvm  /
  └─cs_vbox-swap 253:1    0   2G  0 lvm  [SWAP]
sdb                8:16   0  10G  0 disk 
├─sdb1             8:17   0   2G  0 part 
├─sdb2             8:18   0   2G  0 part 
├─sdb3             8:19   0   2G  0 part 
├─sdb4             8:20   0   1K  0 part 
├─sdb5             8:21   0   2G  0 part 
└─sdb6             8:22   0   2G  0 part 
sdc                8:32   0  10G  0 disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alrighty, good work so far! But there's still one more drive to set up. How can we work a bit more efficiently this time? Checking the utility's menu is a good place to start. The &lt;strong&gt;m&lt;/strong&gt; option will open it. Do you see any options that could be helpful?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command (m for help): m

Help:

  GPT
  M   enter protective/hybrid MBR

  Generic
  d   delete a partition
  F   list free unpartitioned space
  l   list known partition types
  n   add a new partition
  p   print the partition table
  t   change a partition type
  v   verify the partition table
  i   print information about a partition

  Misc
  m   print this menu
  x   extra functionality (experts only)

  Script
  I   load disk layout from sfdisk script file
  O   dump disk layout to sfdisk script file

  Save &amp;amp; Exit
  w   write table to disk and exit
  q   quit without saving changes

  Create a new label
  g   create a new empty GPT partition table
  G   create a new empty SGI (IRIX) partition table
  o   create a new empty DOS partition table
  s   create a new empty Sun partition table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seems we can partition programmatically and fdisk can help us create the script using &lt;strong&gt;O&lt;/strong&gt; (capital) then use that script with &lt;strong&gt;I&lt;/strong&gt; (capital i).  Time to test it out!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk /dev/sdb
[sudo] password for sorad: 

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): O

Enter script file name: disk_layout

Script successfully saved.

Command (m for help): q
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The partition scheme has been saved in a file named disk_layout. Let's check the contents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ cat disk_layout
label: dos
label-id: 0x5ace204b
device: /dev/sdb
unit: sectors
sector-size: 512

/dev/sdb1 : start=        2048, size=     4194304, type=83
/dev/sdb2 : start=     4196352, size=     4194304, type=83
/dev/sdb3 : start=     8390656, size=     4194304, type=83
/dev/sdb4 : start=    12584960, size=     8386560, type=5
/dev/sdb5 : start=    12587008, size=     4194304, type=83
/dev/sdb6 : start=    16783360, size=     4188160, type=83
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty straightforward if you ask me. I wonder though, since the partitions are labeled here as sdb, can this script be applied to sdc? It's back into fdisk using &lt;strong&gt;I&lt;/strong&gt; to load the disk layout for sdc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[sorad@dev9 ~]$ sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.37.4).
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/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x3b6f1a7c

Command (m for help): I

Enter script file name: disk_layout

Created a new DOS disklabel with disk identifier 0x5ace204b.
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Created a new partition 3 of type 'Linux' and of size 2 GiB.
Created a new partition 4 of type 'Extended' and of size 4 GiB.
Created a new partition 5 of type 'Linux' and of size 2 GiB.
Created a new partition 6 of type 'Linux' and of size 2 GiB.
Script successfully applied.

Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 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: 0x5ace204b

Device     Boot    Start      End Sectors Size Id Type
/dev/sdc1           2048  4196351 4194304   2G 83 Linux
/dev/sdc2        4196352  8390655 4194304   2G 83 Linux
/dev/sdc3        8390656 12584959 4194304   2G 83 Linux
/dev/sdc4       12584960 20971519 8386560   4G  5 Extended
/dev/sdc5       12587008 16781311 4194304   2G 83 Linux
/dev/sdc6       16783360 20971519 4188160   2G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[sorad@dev9 ~]$ lsblk
NAME             MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda                8:0    0  20G  0 disk 
├─sda1             8:1    0   1G  0 part /boot
└─sda2             8:2    0  19G  0 part 
  ├─cs_vbox-root 253:0    0  17G  0 lvm  /
  └─cs_vbox-swap 253:1    0   2G  0 lvm  [SWAP]
sdb                8:16   0  10G  0 disk 
├─sdb1             8:17   0   2G  0 part 
├─sdb2             8:18   0   2G  0 part 
├─sdb3             8:19   0   2G  0 part 
├─sdb4             8:20   0   1K  0 part 
├─sdb5             8:21   0   2G  0 part 
└─sdb6             8:22   0   2G  0 part 
sdc                8:32   0  10G  0 disk 
├─sdc1             8:33   0   2G  0 part 
├─sdc2             8:34   0   2G  0 part 
├─sdc3             8:35   0   2G  0 part 
├─sdc4             8:36   0   1K  0 part 
├─sdc5             8:37   0   2G  0 part 
└─sdc6             8:38   0   2G  0 part
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the steps check out! We've saved some time by partitioning the sdc disk using the scheme from disk sdb. Pretty neat! Please chime in with any questions, comments, or concerns. In the next article, we'll look at adding file systems to the new partitions.&lt;/p&gt;

&lt;p&gt;If you're still reading then congratulations are in order! You have just read my first post on DEV. What do you think?&lt;/p&gt;

</description>
      <category>redhat</category>
      <category>admin</category>
      <category>storage</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
