-3

Given: So, I have an 8 GB sd card.

TODO: Get raspbian

Solution:

First I delete the partition:

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

After i've created a new partition:

Command (m for help): n
Partition type
  p   primary (0 primary, 0 extended, 4 free)
  e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):  
First sector (2048-15130623, default 2048):  
Last sector, +sectors or +size{K,M,G,T,P} (2048-15130623, default 15130623):  

Created a new partition 1 of type 'Linux' and of size 7.2 GiB.

This is how it looks:

Command (m for help): p
Disk /dev/sdb: 7.2 GiB, 7746879488 bytes, 15130624 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: 0xa208ea74

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        2048 15130623 15128576  7.2G 83 Linux

Setting table:

Command (m for help): t
Selected partition 1

Hex code (type L to list all codes): b
If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information.
Changed type of partition 'Linux' to 'W95 FAT32'.

Saving Changes

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Making it bootable:

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

print:

Command (m for help): p
Disk /dev/sdb: 7.2 GiB, 7746879488 bytes, 15130624 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: 0xa208ea74

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     2048 15130623 15128576  7.2G  b W95 FAT32

Saving changes

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Formating:

Wed Oct 18; 23:57:49; marton;/backup/desktop/programs/images ;  $  sudo mkfs -t vfat /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)

After that I just burned the image:

Wed Oct 18; 23:58:27; marton;/backup/desktop/programs/images ;  $  sudo dd bs=4M if=2017-09-07-raspbian-stretch-lite.img of=/
dev/sdb1 conv=fsync
442+1 records in
442+1 records out
1854590976 bytes (1.9 GB) copied, 461.441 s, 4.0 MB/s

After that the image was visible and mountable, but now when I plug it in :

Thu Oct 19; 09:50:11; marton;/backup/desktop/programs/images ;  $  mount /dev/sdb
mount: can't find /dev/sdb in /etc/fstab
Thu Oct 19; 09:51:30; marton;/backup/desktop/programs/images ;  $  mount /dev/sdb1
mount: can't find /dev/sdb1 in /etc/fstab

QUESTION: WHY IS IT NOT MOUNTABLE ?

Helpful info:

Thu Oct 19; 10:04:53; marton;/backup/desktop/programs/images ;  $  df
Filesystem     1K-blocks      Used Available Use% Mounted on
devtmpfs         1958676         0   1958676   0% /dev
tmpfs            1965996     26480   1939516   2% /dev/shm
tmpfs            1965996      2112   1963884   1% /run
tmpfs            1965996         0   1965996   0% /sys/fs/cgroup
/dev/sda7       40009728  38632340    238892 100% /
/dev/sda7       40009728  38632340    238892 100% /.snapshots
/dev/sda4         166724      4624    162100   3% /boot/efi
/dev/sda7       40009728  38632340    238892 100% /usr/local
/dev/sda7       40009728  38632340    238892 100% /var/spool
/dev/sda7       40009728  38632340    238892 100% /var/lib/mysql
/dev/sda7       40009728  38632340    238892 100% /tmp
/dev/sda7       40009728  38632340    238892 100% /var/opt
/dev/sda7       40009728  38632340    238892 100% /var/lib/pgsql
/dev/sda7       40009728  38632340    238892 100% /var/crash
/dev/sda7       40009728  38632340    238892 100% /var/lib/mariadb
/dev/sda7       40009728  38632340    238892 100% /var/lib/named
/dev/sda7       40009728  38632340    238892 100% /var/lib/mailman
/dev/sda7       40009728  38632340    238892 100% /var/lib/libvirt/images
/dev/sda7       40009728  38632340    238892 100% /var/tmp
/dev/sda7       40009728  38632340    238892 100% /var/log
/dev/sda7       40009728  38632340    238892 100% /srv
/dev/sda7       40009728  38632340    238892 100% /opt
/dev/sda7       40009728  38632340    238892 100% /boot/grub2/x86_64-efi
/dev/sda7       40009728  38632340    238892 100% /boot/grub2/i386-pc
/dev/sda1      314428412 134355888 180072524  43% /backup
/dev/sda8       59510384  14210312  45300072  24% /home


Thu Oct 19; 10:05:29; marton;/backup/desktop/programs/images ;  $  mount | grep media
Thu Oct 19; 10:06:09; marton;/backup/desktop/programs/images ;  $  
Hartun
  • 3
  • 2
  • 6
    Is there any reason you are following this bizarre approach, rather than just installing the image. – Milliways Oct 19 '17 at 08:22
  • @Milliways I've used EXACTLY THE SAME guide with EXACTLY THE SAME COMMANDS to install the image. – Hartun Oct 19 '17 at 09:21
  • 2
    I don't know what you are trying to achieve. Either tell us what you are trying to achieve with this rather odd procedure or just burn the image direct to a SD card as intended. – joan Oct 19 '17 at 09:51
  • @joan yes, sorry, something is going wrong. I want to mount my drive, but it can't. – Hartun Oct 19 '17 at 10:15
  • @joan Thu Oct 19; 09:50:11; marton;/backup/desktop/programs/images ; $ mount /dev/sdb mount: can't find /dev/sdb in /etc/fstab Thu Oct 19; 09:51:30; marton;/backup/desktop/programs/images ; $ mount /dev/sdb1 mount: can't find /dev/sdb1 in /etc/fstab – Hartun Oct 19 '17 at 10:15
  • The Raspberry Pi image is a complete SD card image. It makes no sense to copy it to a partition within an SD card (/dev/sdb1 rather than /dev/sdb) as it is not a file system. – joan Oct 19 '17 at 10:51
  • ok what should I do ? just format it ? – Hartun Oct 19 '17 at 11:37
  • I guess the mount command required mount path as well. From the error message it looks for the entry in fstab, where the ultimate info available to mount the any specific volume. can you add proper entry in fstab & try mounting it ? – HamTheAstroChimp Oct 19 '17 at 11:59
  • Hartun, I must agree with Joan and Milliways. Why are you trying to do this instead of simply burning the completed .img file provided by the foundation? – Jacobm001 Oct 19 '17 at 16:35
  • @Jacobm001 Well, I am asking what did I do wrong, if you new the answer, instead of critisizing me, maybe, you could have just told me that I don't have to partition and format my device. I don't know that, probably that's why I am asking. – Hartun Oct 19 '17 at 17:36
  • @Hartun: Knowing intent helps answer questions. Users on the SE network often fall victim to the XY problem, and without knowing intent, answers are often wrong. – Jacobm001 Oct 19 '17 at 17:52

1 Answers1

0

Because the Raspbian image is not a filesystem image, it's a device image. It is intended to be used like this:

dd bs=4M if=2017-09-07-raspbian-stretch-lite.img \
   of=/dev/sdb conv=fsync
           ^^^

Note, not sdb1 (a partition, into which you could usefully copy a filesystem), but a block device node. Admittedly, a partition device node can also be considered a block device (because it is random access), but hopefully the point is clear.

When you write the Raspbian image to a device, it will overwrite everything, so there is no point in preformatting the card. When it is done, there will be two partitions (and an MBR, so it is bootable), but those all come from the image.

Note that you can create the card by formatting it with partitions and then copying stuff in from the partitions in the image, but to do that you need to either mount the image, or else do some math based on fdisk -l raspbian.img and copy over the partitions (in which case you don't have to format them, just create the partition table). However, there is not much point to that.

goldilocks
  • 58,859
  • 17
  • 112
  • 227