11

I'm not sure what is wrong here but when running fdisk -l I don't get an output, and when running

    fdisk /dev/sdb # I get this
fdisk: unable to open /dev/sdb: No such file or directory

I'm running Ubuntu 12.10 Server
Can someone please tell me what I'm doing wrong? I want to delete /dev/sdb2-3 and just have one partition for sdb
The only thing I've done differently with the setup of this server is use ext4 instead of ext3, I figured the extra speed of ext4 would help since I am using SSDs now

root@sb8:~# ll /dev/sd*
brw-rw---- 1 root disk 8,  1 Nov 23 14:58 /dev/sda1
brw-rw---- 1 root disk 8,  2 Nov 23 14:55 /dev/sda2
brw-rw---- 1 root disk 8, 17 Nov 23 19:20 /dev/sdb1
brw-rw---- 1 root disk 8, 18 Nov 23 15:45 /dev/sdb2
brw-rw---- 1 root disk 8, 19 Nov 23 14:51 /dev/sdb3
brw-rw---- 1 root disk 8, 33 Nov 23 15:47 /dev/sdc1
brw-rw---- 1 root disk 8, 49 Nov 23 15:48 /dev/sdd1

root@sb8:~# cat /proc/partitions
major minor  #blocks  name

   8        0  117220824 sda
   8        1  112096256 sda1
   8        2    5119968 sda2
   8       16  117220824 sdb
   8       17   20971520 sdb1
   8       18   95718400 sdb2
   8       19     526304 sdb3
   8       48 1953514584 sdd
   8       49 1863013655 sdd1
   8       32 1953514584 sdc
   8       33 1863013655 sdc1

root@sb8:~# ll /dev/disk/by-path/
total 8
drwxr-xr-x 2 root root 4096 Nov 23 15:48 ./
drwxr-xr-x 5 root root 4096 Nov 23 15:42 ../
lrwxrwxrwx 1 root root   10 Nov 23 14:58 pci-0000:00:1f.2-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root   10 Nov 23 19:20 pci-0000:00:1f.2-scsi-1:0:0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root   10 Nov 23 15:45 pci-0000:00:1f.2-scsi-1:0:0:0-part2 -> ../../sdb2
lrwxrwxrwx 1 root root   10 Nov 23 15:47 pci-0000:00:1f.2-scsi-2:0:0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root   10 Nov 23 15:48 pci-0000:00:1f.2-scsi-3:0:0:0-part1 -> ../../sdd1

root@sb8:~# df -T /dev
Filesystem     Type 1K-blocks    Used Available Use% Mounted on
/dev/root      ext4 111986032 1993108 104388112   2% /
Goulash
  • 564
  • 1
  • 9
  • 18
  • 2
    There are missing entries in `/dev`. Have you modified the udev configuration? What's the output of `cat /proc/partitions`? – Gilles 'SO- stop being evil' Nov 23 '12 at 23:49
  • I've added the output to the question, no I haven't modified anything, only installed it today and the first thing I did was try to setup the drives properly – Goulash Nov 23 '12 at 23:51
  • 2
    That's a weird one. Normally the entries for the whole disk (`/dev/sdb`, etc.) should be created at the same time as the entries for the partitions. What do you have in `/dev/disk/by-path`? What's the output of `df -T /dev`? – Gilles 'SO- stop being evil' Nov 24 '12 at 00:03
  • Question updated with those outputs – Goulash Nov 24 '12 at 00:06
  • 1
    Oh, `/dev` isn't tmpfs. That's bad. Now to figure out why this is happening... I wrote an answer with the low-hanging fruit. If that doesn't help you, post the content of `/etc/fstab`, and describe what you did by “try to setup the drives properly”. Did you modify files under `/etc`? under `/lib`? under `/dev`? – Gilles 'SO- stop being evil' Nov 24 '12 at 00:20
  • "Trying to setup the drives properly": well all I did was get confused at the output of `fdisk -l` and then mounted `/dev/sdc1` and `/dev/sdd1` I haven't changed anything else in the disks config since that and posting here – Goulash Nov 24 '12 at 00:23
  • If you do run `sudo mount /dev`, what happens? – Gilles 'SO- stop being evil' Nov 24 '12 at 00:37

2 Answers2

7

On most non-embedded Linux installations, and many embedded installations, /dev is on a RAM-backed filesystem, not on the root partition. Most current installations have /dev as a tmpfs filesystem, with the udev daemon creating entries when notified by the kernel that some hardware is available. Recent kernel offer the possibility of having /dev mounted as the devtmpfs filesystem, which is directly populated by the kernel.

I think Ubuntu 12.10 still uses udev. Either way, /dev should not be on the root partition (as shown by the output of df /dev), it should be on its own filesystem. Did you accidentally unmount /dev?

The first thing you should try is to reboot: this should mount /dev properly. Before that, check that you haven't added an entry for /dev in /etc/fstab (there should be no line with /dev in the second column).

Even with /dev on the root partition, you can create /dev/sdb by running

cd /dev
sudo MAKEDEV sdb

But not having /dev managed dynamically isn't a stable configuration, you'll run into similar problems for a lot of other hardware.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • there is an entry for /dev in `/etc/fstab` this: `dev /dev devtmpfs rw 0 0` Should I just remove it? – Goulash Nov 24 '12 at 00:20
  • @King Was it part of the default installation? (I haven't seen any 12.10 installation yet…) If so, leave it there. It hasn't had the effect it should have had. Try `mount /dev`. Does the problem persist if you reboot? – Gilles 'SO- stop being evil' Nov 24 '12 at 00:22
  • I don't know if it was, this is on a remote server, the only configuring I did was setup the root partition size and swap on sda1, before letting the datacenter's automated installation run, I'll try rebooting – Goulash Nov 24 '12 at 00:26
  • All is the same after a reboot – Goulash Nov 24 '12 at 00:28
  • Should I just use `makedev` or is that going to cause issues? – Goulash Nov 24 '12 at 00:30
  • `/dev` does not appear in the output from `df -h` maybe it's not mounting properly? – Goulash Nov 24 '12 at 00:35
  • @King `MAKEDEV` will solve your immediate issue, because it will permanently create the entries that you specify. But if you ever plug in new hardware, you'll run into the same issue for that hardware. That might be workable on a server with a hardware configuration that doesn't change often, it wouldn't be on a desktop or laptop where you plug in USB peripherals in daily use. I'm out of ideas as to why `/dev` isn't mounted properly, this requires someone with experience with Ubuntu 12.10 – Gilles 'SO- stop being evil' Nov 24 '12 at 00:36
  • It's a server so the hardware only ever changes if I break something, the reboot has caused this btw: ` dev devtmpfs 32970936 0 32970936 0% /dev` – Goulash Nov 24 '12 at 00:38
  • mounting /dev has fixed it :D tyvm :D – Goulash Nov 24 '12 at 00:40
  • I know this question is 5 years old now, but I think that I should point out that running `sudo mount /dev` is what worked to fix the problem, which was actually Gilles' comment on the question. Not in fact using `MAKEDEV` that's in this answer. – Goulash Dec 11 '17 at 18:09
  • @King Do you have to write the command after each reboot, or `/etc/fstab` do its job ? – user285259 Dec 12 '17 at 08:01
  • @user285259 I only had to run the command once, and `/etc/fstab` successfully mounted `/dev` on reboots from then on. It seemed to be a one-off problem that occurred immediately after a re-install. – Goulash Dec 12 '17 at 13:16
1

Most of the time this message occurs after one partition and you do not reread device partition table which was already loaded.

A simple partprobe or kpartx -u /dev/sdb1 (/dev/sdb1 is the new partition number to load into partition table) should be enough.

partprobe or kpartx -u /dev/sdb1

  • I added partprobe to my own script, and still see the same issue. Funnily enough, if I just run the same command again, it works. – Eliezer Miron Jul 02 '21 at 21:55