Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Trying to better understand devices and how to be able to uniquely identify a SD card. I've included comments on my understanding as well as a couple questions. If anything looks out of whack or there are other steps I should be doing, please comment. Also, as mentioned below, I never really did find a unique identifier for the actual SD device. Thanks
A couple ways to determine what is currently mounted.
Code:
michael@rpi1:~ $ mount
/dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=468152k,nr_inodes=117038,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
tmpfs on /etc/machine-id type tmpfs (ro,mode=755)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
michael@rpi1:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 3.8G 11G 28% /
devtmpfs 458M 0 458M 0% /dev
tmpfs 462M 0 462M 0% /dev/shm
tmpfs 462M 47M 416M 11% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 462M 0 462M 0% /sys/fs/cgroup
/dev/mmcblk0p1 41M 21M 20M 52% /boot
Mount some devices. Questions:
1. Why can I mount sda1, 5, 6, and 7, but sda?
2. Why can't I mount /dev/sda2? What does "superblock" mean?
3. sda7 seems like /root when accessing the device, right? What is the purpose of the other partitions?
Code:
michael@rpi1:~ $ sudo mount /dev/sda /mnt
mount: wrong fs type, bad option, bad superblock on /dev/sda,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
michael@rpi1:~ $ sudo mount /dev/sda1 /mnt
michael@rpi1:~ $ ls /mnt
bcm2708-rpi-b.dtb bcm2709-rpi-2-b.dtb bootcode.bin defaults os recovery7.img recovery.elf recovery.img riscos-boot.bin
bcm2708-rpi-b-plus.dtb bcm2710-rpi-3-b.dtb BUILD-DATA INSTRUCTIONS-README.txt overlays recovery.cmdline RECOVERY_FILES_DO_NOT_EDIT recovery.rfs System Volume Information
michael@rpi1:~ $ sudo umount /dev/sda1
michael@rpi1:~ $ sudo mount /dev/sda2 /mnt
mount: /dev/sda2: can't read superblock
michael@rpi1:~ $ sudo mount /dev/sda5 /mnt
michael@rpi1:~ $ ls /mnt
cache installed_os.json lost+found noobs.conf os wpa_supplicant.conf
michael@rpi1:~ $ sudo umount /dev/sda5
michael@rpi1:~ $ sudo mount /dev/sda6 /mnt
michael@rpi1:~ $ ls /mnt
bcm2708-rpi-0-w.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb bcm2710-rpi-cm3.dtb cmdline.txt COPYING.linux fixup.dat fixup_x.dat kernel7.img LICENCE.broadcom os_config.json start_cd.elf start.elf
bcm2708-rpi-b.dtb bcm2708-rpi-cm.dtb bcm2710-rpi-3-b.dtb bootcode.bin config.txt fixup_cd.dat fixup_db.dat issue.txt kernel.img LICENSE.oracle overlays start_db.elf start_x.elf
michael@rpi1:~ $ sudo umount /dev/sda6
michael@rpi1:~ $ sudo mount /dev/sda7 /mnt
michael@rpi1:~ $ ls /mnt
bin boot dev etc home lib lost+found media mnt opt proc root run sbin srv sys tmp usr var
michael@rpi1:~ $ df -h
michael@rpi1:~ $ sudo umount /dev/sda7
Get info using blkid. Why can I only see /dev/mmcblk0 using sudo? While some of the UUIDs might be unique, surely 3461-3439 and others are not. What is the purpose of these UUIDs? There still does not appear anything which uniquely identifies the device but only some partitions on the device.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
Code:
$ ls -al /dev/disk/by-uuid
will give you a unique identifier for each drive. Dev/sda is the whole disk. It contains a number of file systems. You can mount the file systems, but not the whole drive. There are some exceptions, but that's why in your case.
Dev/sda2 might be a swap area, which won't mount with mount.
So, I have a UUID for sda1, sda5, sda6, and sda7. sda2 as you indicate is likely for swap. Any reason there is not a sda3 or sda4?
sda1. Looks like a partition for NOOBs?
sda5 and sd6. Also looks like it is related to installation? Or maybe a boot (what does this really mean?) partition?
sda7. The filesystem which will be mounted as /. Other than looking for familiar files or directories, how would one know this?
Would sda7 be the most appropriate?
Code:
michael@rpi1:~ $ ls -al /dev/disk/by-uuid
total 0
drwxr-xr-x 2 root root 160 Dec 12 13:24 .
drwxr-xr-x 7 root root 140 Dec 11 03:06 ..
lrwxrwxrwx 1 root root 10 Dec 12 13:24 3461-3439 -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 12 13:24 7060-423E -> ../../sda6
lrwxrwxrwx 1 root root 15 Dec 11 03:06 70CE-EB76 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 Dec 12 13:24 85cbdbf9-b8b0-4629-b25d-860937c2c0e0 -> ../../sda5
lrwxrwxrwx 1 root root 10 Dec 12 13:24 ce42dd60-6b4c-46be-9e92-066555a5467f -> ../../sda7
lrwxrwxrwx 1 root root 15 Dec 11 03:06 f2100b2f-ed84-4647-b5ae-089280112716 -> ../../mmcblk0p2
michael@rpi1:~ $
sda2 is an extended partition which is a container for logical partitions (5,6,7). Its how you can create more then 4 partitions using a legacy MBR formatted disk. It can not be mounted.
A superblock basically is the metadata of the filesystem. It contains all the information about the filesystem and files stored within.
Hard disk drives contain firmware which contains the model number, serial number etc. USB flash drives have the same information but is read when the drive is enumerated i.e. when it is plugged in to the computer. I have never tried running the hdparm -I command to see what happens.
Looks like most of the USB attributes are from the card reader and host controller.
I think I am blind. I didn't notice this one (copied from my previous post).
Code:
michael@rpi1:~ $ ls -al /dev/disk/by-uuid
total 0
drwxr-xr-x 2 root root 160 Dec 12 13:24 .
drwxr-xr-x 7 root root 140 Dec 11 03:06 ..
lrwxrwxrwx 1 root root 10 Dec 12 13:24 3461-3439 -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 12 13:24 7060-423E -> ../../sda6
lrwxrwxrwx 1 root root 15 Dec 11 03:06 70CE-EB76 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 Dec 12 13:24 85cbdbf9-b8b0-4629-b25d-860937c2c0e0 -> ../../sda5
lrwxrwxrwx 1 root root 10 Dec 12 13:24 ce42dd60-6b4c-46be-9e92-066555a5467f -> ../../sda7
lrwxrwxrwx 1 root root 15 Dec 11 03:06 f2100b2f-ed84-4647-b5ae-089280112716 -> ../../mmcblk0p2
michael@rpi1:~ $
And then when I remove the SD reader:
Code:
michael@rpi1:~ $ ls -al /dev/disk/by-uuid
total 0
drwxr-xr-x 2 root root 80 Dec 12 15:14 .
drwxr-xr-x 7 root root 140 Dec 11 03:06 ..
lrwxrwxrwx 1 root root 15 Dec 11 03:06 70CE-EB76 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 15 Dec 11 03:06 f2100b2f-ed84-4647-b5ae-089280112716 -> ../../mmcblk0p2
michael@rpi1:~ $
And then when I put the SD in another RPi, and do the same, I get the following..
Code:
michael@rpi2:~ $ ls -al /dev/disk/by-uuid
total 0
drwxr-xr-x 2 root root 120 Dec 12 15:52 .
drwxr-xr-x 7 root root 140 Dec 12 15:52 ..
lrwxrwxrwx 1 root root 15 Dec 12 15:52 3461-3439 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 15 Dec 12 15:52 7060-423E -> ../../mmcblk0p6
lrwxrwxrwx 1 root root 15 Dec 12 15:52 85cbdbf9-b8b0-4629-b25d-860937c2c0e0 -> ../../mmcblk0p5
lrwxrwxrwx 1 root root 15 Dec 12 15:52 ce42dd60-6b4c-46be-9e92-066555a5467f -> ../../mmcblk0p7
michael@rpi2:~ $ sudo fdisk -l
...
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 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
Disklabel type: dos
Disk identifier: 0x00009590
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 2496093 2487902 1.2G e W95 FAT16 (LBA)
/dev/mmcblk0p2 2496094 62333951 59837858 28.5G 5 Extended
/dev/mmcblk0p5 2498560 2564093 65534 32M 83 Linux
/dev/mmcblk0p6 2564096 2699263 135168 66M c W95 FAT32 (LBA)
/dev/mmcblk0p7 2703360 62333951 59630592 28.4G 83 Linux
michael@rpi2:~ $
Okay, rpi1 has a 16GB SD, and maybe two partitions (mmcblk0p1 and mmcblk0p2).
And rpi2 has a 32GB SD, and maybe four partitions (mmcblk0p1 and mmcblk0p5 plus mmcblk0p6 and mmcblk0p7 plus the elusive sda2).
And I see the UUIDs on the SD as well as the device.
Still don't know what it all means, but definitely a pattern
Last edited by NotionCommotion; 12-12-2017 at 10:12 AM.
I'm not sure what you are looking at but the only difference is the device ID. /dev/mmcblk0 is the SD card slot on the PI and /dev/sda is when you plug the card into a USB card reader.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.