Guilt and a gift

This isn’t a religious or spiritual piece. But I know there are parallels in those spheres that can’t be sufficiently explained in words or thoughts with a reasonable sense of fulfillment.

So I’m going to make it short and hopefully write this one like a drop of sandalwood oil on a diffuser stick.

I have made many choices in my life, some impact only me and some impact my near and dear ones. Not all of them ended up with consequences that I imagined them to have. So there’s regret and frustration. But even under all that, is an unfulfilling feeling of guilt. Guilt that my choices have consequences that impede the choices others can make. This guilt is at the pits of my stomach. It makes me aware of its presence when I start thinking of moving to another locality to save some money on rent, but will also impact the school my children attend, and thereby the company they keep. It reminds me of already having deprived them from the doting and pampering affection of their grandparents when I moved to a different place for better education and job prospects-for myself. This guilt bullies me to find meaning and purpose.

In the choices and consequences that gloriously failed, there is also a thin silver lining that shows me the people who have stood by me. Allowing me to make those choices. Giving me a sense of safety and liberty. It warms and sweetens my experience of every interaction. It is an ever-present foundation that was laid by my parents when they were educating me through the trials and tribulations of life. It is a gift that keeps on giving and empowers. Gratitude is that gift which encourages me to stay the course of discovering my own meaning and purpose.

Vetala Panchavimshati (वेताल पंचाविंशति), Crusts and Matthew 5:5

To many of you, the first story I’m about to reference, might be familiar as being in the “Panchatantra” or “Jataka tales”. Let me tell you, it is from the 24 stories set in social-morality that vetala (a goblin/spirit) recited to King Vikramaditya and tested his wise judgement. In Sanskrit, Panchavimshati means 25. The 25th story is the narrative and complication within which the other 24 stories are set like jewels.

The moral conundrums posed by vetala are nothing new to my generation of kids who grew up watching them on doordarshan or read the Jataka/Panchatrantra stories that frequently referenced them. Somehow, not many in the next generation have been introduced to them. I strongly encourage you to read these stories and relay them to your children. Discuss them with your parents and community because we need to preserve some semblance of structure, morality, civility and self-esteem for our children’s generations. Amazon link to buy a book.

Smartest of the four brothers?

The story loosely goes like this…. A brahmin couple had 4 kids and some very nasty greedy relatives. After the father’s death, the relatives usurped his wealth, sparing nothing for his children. The four boys, educated as they were in different mantra, tantra and shastra, decided to make it big when a nearby king sought the counsel of learned men. One of the brothers wasn’t as academically bright and incisive as the others, being only useful in menial vocational jobs, but they decided to take him also with them.

Enroute to the king’s court, they stumbled on a pile of bones. The three brilliant educated and eager brothers thought this was a grand opportunity for each of them to exemplify and outshine the others. So the first used his knowledge to reorganize the bones in the right manner. The second used his knowledge to enclose them in skin, flesh and fur. The third brother proclaiming to have the highest knowledge to restore life, was just about to do it when the fourth stopped him and warned of the impending danger that a hungry wild lion could pose. Drunk in their knowledge and power to undo nature, the other three bullied him. So he climbed a nearby tree and settled carefully on a strong branch to observe what was to happen.

No sooner than the fourth brother settled, the third brother brought the lion back to life. The beast sprung on the three and killed them in one slash of its paw. The fourth brother unable to stop his brothers and also unable to act swiftly to stop the lion, watched with pain and horror as the lion devoured the three to satisfy its hunger.

Crusts

This second story I refer, is “Crusts” a children’s book by Danny Parker. It has a very powerful undercurrent that establishes the pattern of learning/development. The story is about some aliens living on a planet made of crusts. For some reason their planet is crumbling away and they need planet loads of crusts to save themselves. The protagonist is a playful kid who doesn’t like to eat the crusts on his breads but uses them for other purposes.

The aliens initially think they can rely on this kid to provide all the crusts they need to save their planet. However, the kid doesn’t seem to go with their plan. He plays with his crusts, makes useless art or menial garnen tools with them. All the while, it is clear as the story progresses, that the kid is developing a deeper understanding of different types of crusts and their specialized uses to address specific concerns.

Just when the aliens drop all hope and return to their planet, the kid makes a giant rocketship using just crusts, loads it with even more crusts and takes it across space to save their planet.

The story beautifully illustrates the preferred stages of learning a new skill or tool. Play, experiment, use it to express the mind, employ it to solve problems.

Matthew 5:5

You can read exactly what I’m referring to, over here.

These stories and thoughts have fused in my mind, and I can’t stop seeing the patterns that have played out on use, misuse and abuse of stones, metals, gun powder and information technology over the several millennia of human existence.

In this environment… Enter AI.

Linux | XFS filesystem on logical partition

This post is a result of 1 day’s worth of fiddling with bash to make an xfs type filesystem on a logical partition. I’m still learning this so some concepts might not be sufficiently elaborated. Use this as a quick lookup and I encourage more reading. If you want to skip all the drama and to get to the point, jump to The Process.

I could’ve done this with much less heartache using the GUI but where’s the fun in that! Such is the masochism of a new tux convert. I was sort of a tux-agnost earlier…..

First things first. Acknowledgements are due to my friends Suhas and Balaji who introduced me to Redhat, Knoppix, Fedora, Mandrake, BSD and Ubuntu between 2001 and 2007. I wasn’t too enthusiastic about all that back then but they’re my friends and seemed upbeat about it… so whatever fanned their sail!!! What happened after 2007? I became a .NET developer. MS-DOS baby!!!!

15 years hence, I’m kind of bored and irritated by Microsoft regurgitating LAMP, Fedora, .NET Framework-Core-Standard-6(old-wHine-new-bottle hocus pocus). I quit my job and am looking to expand my software & system engineering artistic expression.

Am now a CompTIA Network+ certified engineer. And I’m happy I did it. While studying for this certification, I developed an increased respect for my Electronics and Communication Engineering course 2003-2007…. That felt good!

I was frequently reminded of those early experiences with Linux. Back then, I had two 256 MB Seagate hard drives, one LG CD-DVD drive, a 3 1/2″ floppy drive, 30-40 2HD Amkette/Sony floppies and a 128 MB Corsair SDRAM. Not to forget, all this was useless without spare IDE cables, hard-drive jumper pins, GRUB and Partition Magic 8.

In the past 15 years, I’ve definitely used and managed some “stuff” hosted on Linux, thanks to the exposure from earlier and in general, thank you stackoverflow. But I always felt that mix of fear and uncertainty during each encounter. I only knew the beast’s name and nature. Not my ability to deal with it when unleashed. Now I’m facing those fears, prodding those timid memories. It ends now! I’m studying to get certified on Linux. CompTIA Linux+ की जय!

FHS, file, directory, user, group, permissions, daemons, services, protocols, … all done. Surprisingly, not at all daunting! Then I start studying about partition tables, linked files, filesystems. How hard can it be! ext2, swap and boot were my friends right? Right? RIGHT???? And my naivety is hung out to dry.

The Process

I could’ve done this with much less heartache using the GUI but where’s the fun in that! Such is the masochism of a new convert. I was sort of a tux-agnost earlier. Deja vu! Eerily familiar feelings now. I’m working with fdisk, gdisk and parted here.

After everything was done, this is what parted -l showed. Specifically note /dev/sdb5.

[root@centosmin ~]# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
 
Number  Start   End     Size    Type      File system     Flags
 1      1049kB  1075MB  1074MB  primary   xfs             boot
 2      1075MB  6443MB  5369MB  primary   xfs
 3      6443MB  9663MB  3219MB  primary   ext4
 4      9663MB  10.7GB  1075MB  extended
 5      9665MB  10.7GB  1073MB  logical   linux-swap(v1)
 
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
 
Number  Start   End     Size    Type      File system  Flags
 1      1049kB  1075MB  1074MB  primary   ext4
 2      1075MB  2147MB  1073MB  extended
 5      1076MB  2147MB  1072MB  logical   xfs
 
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
 
Number  Start   End     Size    File system     Name              Flags
 1      1049kB  1075MB  1074MB                  Linux filesystem
 2      1075MB  2147MB  1073MB  linux-swap(v1)  Linux swap

sdb and sdc are 2GB virtual .vdi drives carved out just for this purpose.

In the standard MS-DOS Master Boot Record(for more than one reason, MS-DOS has lost its luster), we can only have a maximum of 4 partitions. So if we need to make more than 4, the standard process is to create 3 primary partitions, 1 extended partition and within that extended partition, create as many logical partitions as we need. Sounds easy.

/dev/sda was partitioned by the installer. Thankfully. I did have some recollection to keep /var, /tmp and others separate from /.

Trying out fdisk to make an MBR at /dev/sdb… I wanted to make 1 primary ext4, 1 logical xfs.

This is what I started with:

[root@centosmin ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sdb: 2147 MB, 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
Disk label type: dos
Disk identifier: 0x000d51ee

   Device Boot      Start         End      Blocks   Id  System

First, the ext4 primary partition:

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4194303, default 2048):↵
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +1G
Partition 1 of type Linux and of size 1 GiB is set

Command (m for help): p

Disk /dev/sdb: 2147 MB, 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
Disk label type: dos
Disk identifier: 0x000d51ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Next, create the enclosing extended partition as sdb2.

Command (m for help): p

Disk /dev/sdb: 2147 MB, 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
Disk label type: dos
Disk identifier: 0x000d51ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2): 2
First sector (2099200-4194303, default 2099200):↵
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-4194303, default 4194303):↵
Using default value 4194303
Partition 2 of type Extended and of size 1023 MiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@centosmin ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

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: 2147 MB, 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
Disk label type: dos
Disk identifier: 0x000d51ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     4194303     1047552    5  Extended

Now create the logical partition sdb5. By default, the logical partition will get created inside the sdb2 extended partition space.

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (2101248-4194303, default 2101248):↵
Using default value 2101248
Last sector, +sectors or +size{K,M,G} (2101248-4194303, default 4194303):↵
Using default value 4194303
Partition 5 of type Linux and of size 1022 MiB is set

Command (m for help): p

Disk /dev/sdb: 2147 MB, 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
Disk label type: dos
Disk identifier: 0x000d51ee

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     4194303     1047552    5  Extended
/dev/sdb5         2101248     4194303     1046528   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

At this point, I thought I needed to change the system ID of sdb5 to something that reflected ‘XFS’. So I needed to change it to ‘5’???

Command (m for help): t
Partition number (1,2,5, default 5): 5
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 ❤ 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 5

You cannot change a partition into an extended one or vice versa.
Delete it first.

Type of partition 5 is unchanged: Linux

But what’s this? The default system ID indicates that the logical partition is of type EXT4 and I can’t change it to XFS?

I fiddled around fdisk with no luck No matter what I did, the new logical partition *Always* had system ID 83… same as sdb1. Read a few blogs but something seemed missing. They always jumped from creating the partition to calling it XFS without showing any evidence. No matter what site I followed, I got the same recommendations and the same result. Was there another config-default file which specified the default system ID for new partitions?

I switched tack and started using parted and didn’t have an issue. So how come so many people using fdisk haven’t mentioned anything about using parted as an intermediate step? Did everyone omit the same “seemingly trivial” step? I had to know! It wasn’t until I mistakenly tried fdisk to create the partition and then checkd using parted, that I saw the same output as I got with parted.

On checking this listing with parted -l, I was able to confirm, sdb5 was indeed of type XFS.

[root@centosmin ~]# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  1075MB  1074MB  primary   ext4
 2      1075MB  2147MB  1073MB  extended
 5      1076MB  2147MB  1072MB  logical   xfs

To seal the deal, I used mkfs aliases to make the filesystems.

[root@centosmin ~]# ls -l /usr/sbin/mkfs*
-rwxr-xr-x. 1 root root  11520 Oct  1  2020 /usr/sbin/mkfs
-rwxr-xr-x. 1 root root 375240 Aug  7  2017 /usr/sbin/mkfs.btrfs
-rwxr-xr-x. 1 root root  37024 Oct  1  2020 /usr/sbin/mkfs.cramfs
-rwxr-xr-x. 4 root root  96336 Oct  1  2020 /usr/sbin/mkfs.ext2
-rwxr-xr-x. 4 root root  96336 Oct  1  2020 /usr/sbin/mkfs.ext3
-rwxr-xr-x. 4 root root  96336 Oct  1  2020 /usr/sbin/mkfs.ext4
-rwxr-xr-x. 1 root root  37136 Oct  1  2020 /usr/sbin/mkfs.minix
-rwxr-xr-x. 1 root root 368432 Oct  1  2020 /usr/sbin/mkfs.xfs

[root@centosmin ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

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

[root@centosmin ~]# mkfs.xfs /dev/sdb5
mkfs.xfs: /dev/sdb5 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
[root@centosmin ~]# mkfs.xfs -f /dev/sdb5
meta-data=/dev/sdb5              isize=512    agcount=4, agsize=65408 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=261632, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Moral of the story… if you have different tools to do the same job, find out how each of them can help you get the desired outcome.

All is well that ends well. Tchuss!