itoffshore / alpine-linux-scripts

Alpine Linux Setup Scripts
GNU General Public License v2.0
46 stars 13 forks source link

newly created partition not found in /dev/ #2

Closed Lem closed 9 years ago

Lem commented 9 years ago

Expected: sda1 + sda2 in /dev

Problem: Only sda2 is available. sda1 listed by most tools (lsblk, cat /proc/paritions, ...) but not found in /dev

Background: Using a fresh harddrive-image via virtualbox

Some more output:

Alpine Linux Custom Installation:

Installing applications for setup ...

 * Caching service dependencies ...                                                                                               [ ok ]
 * Starting networking ...
 *   lo ...                                                                                                                       [ ok ]
 *   eth0 ...
ifup: interface eth0 already configured                                                                                           [ ok ]
 * Starting haveged ...                                                                                                           [ ok ]

NAME       SIZE       VENDOR     LABEL 
sda        8G         ATA                  

Choose Disk [ sda ]
>>>[ sda ]: 

Choose Partition Scheme [  ]
>>>[ m(br) | g(pt) ]: m

Choose Disk Layout [ none ]
>>>[ l(vm) | b(oot) | none ]: b
Alpine Linux Custom Installation:

DOS MBR written to /dev/sda

NAME         TYPE     FSTYPE        MOUNT@     FORMAT@         
├─sda1  100M part     ---           ---        ---                 
└─sda2  7.9G part     ---           ---        ---                 

 Choose device to configure?              [ q to Quit ]
>>>[ sda1 ... sda2 ]: sda2

Create LUKS device on '/dev/sda2' ? [ y/N ] : y
Wipe LUKS partition: '/dev/sda2' with random data? [ y/N ] : 
LUKS settings: -c aes-xts-plain64 -s 256 -h sha512 -i 5000 [ c to configure ] : 
Creating crypt on /dev/sda2: -c aes-xts-plain64 -s 256 -h sha512 -i 5000 --use-random

WARNING!
========
This will overwrite data on /dev/sda2 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter passphrase: 
Verify passphrase: 
Enter LUKS device mapper name: bla
Enter passphrase for /dev/sda2: 
Configure LVM on '/dev/mapper/bla' ? [ y/N ] : 

Enter Mount point for /dev/mapper/bla? [ /mnt/bla ] : 

Select filesystem to create? [ ext4 ]: 
>>>[ ext2 ext3 ext4 swap btrfs none = n ]: ext4

Alpine Linux Custom Installation:

NAME          TYPE     FSTYPE         MOUNT@      FORMAT@         
├─sda1   100M part     ---            ---         ---                 
└─sda2   7.9G part     crypto_LUKS    ---         ---                 
  └─bla  7.9G crypt    ---            /mnt/bla    none                

 Choose device to configure?                 [ q to Quit ]
>>>[ sda1 ... bla ]: q

/dev/mapper/bla none

Format the above partitions? [ y/N ] : y
mounting /dev/mapper/bla @ /mnt/bla
mount: /dev/mapper/bla is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/mapper/bla,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

NAME     SIZE TYPE  FSTYPE      MOUNTPOINT PARTLABEL UUID
sda        8G disk                                   
├─sda1   100M part                                   
└─sda2   7.9G part  crypto_LUKS                      e1a31abe-22b4-412b-b6d6-029989bb68ea
  └─bla  7.9G crypt                                  
localhost:~# 
localhost:~# ./setup-disk -m sys -E

Select LUKS ROOT Device Mapper:

bla
Boot Device '/dev/sda1' is not mounted.
localhost:~# mkfs.ext2 /dev/sda1
mke2fs 1.42.13 (17-May-2015)
The file /dev/sda1 does not exist and no size was specified.
localhost:~# lsblk 
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0     8G  0 disk  
├─sda1    8:1    0   100M  0 part  
└─sda2    8:2    0   7.9G  0 part  
  └─bla 253:0    0   7.9G  0 crypt /mnt/bla
sr0      11:0    1 299.1M  0 rom   /media/cdrom
loop0     7:0    0  69.2M  1 loop  /.modloop
localhost:~# ls -lah /dev/sda1
ls: /dev/sda1: No such file or directory
Lem commented 9 years ago

Please ignore the fact that I did not format the luks-container on sda2, same problem would appear even if it would be formated.

itoffshore commented 9 years ago

A partition cannot be mounted if it does not contain a filesystem. I will add a check for mounting an unformatted partition.

You cannot run ls on an unmounted device (even if it had a filesystem).

setup-disk correctly detects the boot device is not mounted & exits.

Lem commented 9 years ago

I know that I can't list the content of a device with ls $DEV. My intention was to show that the new created partition sda1 is not accessible via /dev. Even if it does not contain a file-system the partition should be shown as a device.

itoffshore commented 9 years ago

Fixed with https://github.com/itoffshore/alpine-linux-scripts/commit/74a025ec2102aedcbd67c5c8df5f8027bf11210b