3

Background Info

I am currently trying to build a Linux From Scratch (LFS) partition.
This is my first attempt and I'm doing this to challenge myself, but I'm having trouble getting started.

I'm using a Raspberry Pi 3, with a 16gb Micro SD, currently installed with Ubuntu 20.04LTS, as my base.
I'm having trouble allocating the partition though.

My Questions

This is a bit of a jumble of questions, but any additional clarity or recommended reading/research is welcome!

  1. From what I've found so far, it seems that most non-embedded Linux installations, and many embedded installations, may not use /dev/ as the actual partition mounting space? (source) I'm not really clear on what this means though. Do I need to look for a different place to try mounting my new partition?

  2. I also don't see any /dev/sda/, /dev/sdb/, etc in my /dev/. Is this normal for Ubuntu or Ubuntu for SBC's? I feel like this is related to my first question, but still don't have a clear understanding of why it is like this.

  3. Also I saw that using MAKEDEV apparently doesn't make the partition Dynamically managed? Is there a way to set it up to be Dynamically managed, or does it matter since I'm using it to build my LFS partition?

What I've Tried

I tried creating /dev/sda/ with sudo MAKEDEV sda from my /dev/, but I don't have the binaries for MAKEDEV installed apparently. I am currently trying to find the required packages for it (Not sure if this will fix my overall problem or not though, any advice is welcome).

The Layout

user@host:~$ cfdisk /dev/sda
cfdisk: cannot open /dev/sda: No such file or directory


user@host:~$ sudo cfdisk /dev/sda
cfdisk: cannot open /dev/sda: No such file or directory


user@host:~$ cat /proc/partitions
major minor  #blocks  name

   7        0      24084 loop0
   7        2      62720 loop2
   7        3      49608 loop3
   7        4      26564 loop4
   7        5      65316 loop5
   7        6      49956 loop6
 179        0   15558144 mmcblk0
 179        1     262144 mmcblk0p1
 179        2   15294959 mmcblk0p2


user@host:~$ ll /dev/sd*
ls: cannot access '/dev/sd*': No such file or directory


user@host:~$ ll /dev/disk/by-path/
total 0
drwxr-xr-x 2 root root 100 Jan  1  1970 ./
drwxr-xr-x 7 root root 140 Jan  1  1970 ../
lrwxrwxrwx 1 root root  13 Aug  4 23:07 platform-3f202000.mmc -> ../../mmcblk0
lrwxrwxrwx 1 root root  15 Aug  4 23:07 platform-3f202000.mmc-part1 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root  15 Aug  4 23:07 platform-3f202000.mmc-part2 -> ../../mmcblk0p2


Current Thought Process

I am trying to make the /dev/sd*/ partition, with MAKEDEV or some other method, and then proceed with cfdisk to try and complete this part of my build. Any thoughts on this, am I over thinking it, or maybe misunderstanding what I need to do?

1 Answer 1

2

Your system has a SD/MMC card reader that does not use the (originally SCSI-based) unified storage device naming. It uses a different device name style: your whole-disk device is /dev/mmcblk0, and its partitions are listed as mmcblk0p<N> where <N> is the number of the partition. And yes, it's normal for SD/MMC card readers that use a dedicated driver instead of USB Mass Storage interface.

So, you'll want to use sudo cfdisk /dev/mmcblk0 here.

Furthermore, if you are following a generic or x86 hardware oriented "Linux From Scratch" book, you should keep in mind that you'll need to substitute /dev/mmcblk0 for any reference to /dev/sda or similar, whenever and wherever the intended meaning is "my system disk as a whole disk". Likewise, when you see /dev/sda1 as a reference to "the first partition of my system disk", you should substitute /dev/mmcblk0p1 for it. And so on for any other partitions.

No, /dev/ is not a partition mounting space. As far as I know, there is no such thing as a partition mounting space. Any directory anywhere can act as a mount point for another filesystem. If you are wondering where you should make your mount points, then you should probably take a look at the Filesystem Hierarchy Standard (FHS). Although you are entirely free to do your own thing if your choose to do so.

It is generally preferable that a directory should be empty when used as a mountpoint, for any existing contents will be hidden, and the contents of the root directory of the mounted filesystem will be shown in their stead. (In Linux, there are ways for the system administrator to "peek under" a mounted filesystem, but I digress...)

/dev is a directory sub-tree for device nodes (device files). Only them, and sub-directories for them, are generally supposed to be in this sub-tree.

On modern Linux systems, /dev is usually a RAM-based filesystem (type tmpfs or devtmpfs) which is automatically managed by udev. As a result, you will generally only see device nodes for devices that actually exist on your system and have their kernel-level drivers loaded.

For example, if you create a third partition on your SD card, you should see /dev/mmcblk0p3 appear for you automatically. And if you deleted the second partition, /dev/mmcblk0p2 would vanish.

Device nodes are not normal files: they are essentially connection points to a particular device driver in the kernel, and the hardware (or software) device(s) the driver controls.

Before dynamically-managed /dev filesystems were developed, /dev used to be just a directory on the root filesystem, containing device nodes. A set of device nodes would be created at OS installation time, and would persist in the filesystem on disk much like regular files.

(In other words, /dev/ is basically just a mechanism to map a kernel-friendly device specification "block device, driver #179, device #1" to a more human-readable name like /dev/mmcblk0p1 and vice versa.)

The standard method for creating (or re-creating, if deleted for any reason) device nodes would be the mknod command, and a script called MAKEDEV which would use loops of mknod commands to create various standard sets of devices with a single command.

No, MAKEDEV has nothing to do with partitions per se. It also does not make anything (neither device nodes nor partitions) dynamically managed. It is the tool for mass creating old-style statically managed device nodes.

Making your /dev directory tree dynamically managed would most likely involve installing udev. If you are working with LFS, that might come later... perhaps quite a bit later.

Making a partition "dynamically managed" is not really a thing, as far as I know. Unless it is an odd way of say "using Logical Volume Manager (LVM)", perhaps?

4
  • That helps SOO much, this answer is amazing! As a follow up question, since you said that /dev/ isnt actually a partition mount space, is there a place other than /dev/ that you might recommend instead? Currently I think it makes more sense to just leave it as is to follow 'standards'.
    – aRustyDev
    Aug 6, 2020 at 18:39
  • What is the purpose of the partition? If it's for some specific application or similar, you might make a reasonably named directory under /opt/ or /usr/local and mount it there, like /opt/my_cool_app/ or /usr/local/project-z. If it is data that might someday be for some sort of services, then under /srv/, like /srv/photos/ or /srv/multimedia_library.
    – telcoM
    Aug 6, 2020 at 22:17
  • with df I get /dev/mmcblk0p1 in the first column "filesystem" with alpine. Why is the partition listed whereas the device should be without p1? I try to create a persistant storage on the mmc.
    – Timo
    Feb 21 at 17:51
  • 1
    @Timo It appears there is a partition table of some type on the card already, and the mounted filesystem is within the first partition. The Linux kernel will represent any recognized partitions as block devices, and does not care whether you place a filesystem onto a whole-disk device or onto a partition device; both ways work in Linux - but other OSs might care.
    – telcoM
    Feb 21 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .