1

I am trying to create a bootable USB stick using the sudo dd command, but using fdisk -l to find out which USB port the device is , I don't know how to interpret the output.

My computer is a HP Compaq nc6220, with 3 USB ports.

This is the output I am currently getting, with the USB stick plugged into the single USB port on the left of my keyboard:

Disk /dev/sda: 37.3 GiB, 40007761920 bytes, 78140160 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: 0x00029d6e

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 73963519 73961472 35.3G 83 Linux
/dev/sda2       73965566 78139391  4173826    2G  5 Extended
/dev/sda5       73965568 78139391  4173824    2G 82 Linux swap / Solaris


Disk /dev/sdb: 7.5 GiB, 8053063680 bytes, 15728640 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: 0x00000000

I am assuming the /dev/sda lines refer to my computer's internal hard drive, and the /dev/sdb lines refer to the USB stick.

However, previously, when I tried to run fdisk -l with this USB stick, it was giving a different output, with 4 lines, labelled /dev/sdb1, /dev/sdb2, dev/sdb3 and dev/sdb4.

Please can anyone tell me what is going on here (as to why the output has changed, and is it safe for me to use sudo dd if=~/Desktop/linuxmint-18.1-cinnamon-32bit.iso of=/dev/sdb to format the USB stick and make a bootable USB stick so I can install a different distro?

Jos
  • 29,224
  • Is it an 8GB flash drive which is consistent with 7.5GiB. Do you have any data in the 4 partitions on flash drive. The dd will erase partition table and you lose all data, even though ISO is only about 1.5GB. Note that this site is for Ubuntu, and official flavors of Ubuntu, not spin-off versions like Mint. – oldfred Feb 23 '17 at 16:19
  • Thanks Jos and oldfred. Someone [ ;-) ] was very astute to notice that the alteration in the output from fdisk was caused by my using the flash drive since I formatted it. I made the mistake of downloading the iso image to it, then realising what I had done I cut & pasted it onto the desktop. I thought that as long as the flash drive was empty I would be able to change it into the bootable USB stick. Because of your advice I'll format it again before I use it for that purpose. Also, you're probably correct that I shouldn't have used askubuntu for purposes of switching away from Ubuntu. – Rene Thomas Feb 26 '17 at 17:05

2 Answers2

1

Let's go through this part by part.

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 73963519 73961472 35.3G 83 Linux
/dev/sda2       73965566 78139391  4173826    2G  5 Extended
/dev/sda5       73965568 78139391  4173824    2G 82 Linux swap / Solaris

In this output we see that you have a block device (be it a hard-drive or ssd) represented by /dev/sda device file, with 3 partitions. Since we see here that you have Linux partition ( likely ext4 filesystem) and swap partition, it is safe to assume this is where your Ubuntu resides.

Disk /dev/sdb: 7.5 GiB, 8053063680 bytes, 15728640 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: 0x00000000

There we see a block device represented by /dev/sdb file. Since it is 7.5 GiB ( note, this is different from GB ) and dos filesystem, it's safe to assume this is your USB drive.

NOTE: /dev/sdb doesn't mean you have connected your USB drive to particular USB port. This only gives a representation to your device. You need to use lsusb to find out which particular USB port is used.

The fact that output doesn't show /dev/sdb1 and /dev/sdb2 likely suggests that after formatting the disk, the partitions were removed from the drive. My first guess would be that your USB disk became unmounted but quick test with my own USB suggests otherwise.

As for the dd command, typically it should be expected that partitions should be created and what you mentioned about /dev/sdb1 and /dev/sdb2 suggests to me your USB was formatted appropriately; also, it is typical to specify block size when writing iso, so you should specify block size via bs=4M to write the iso image in blocks of 4096 MiB:

sudo dd bs=4M if="~/Desktop/linuxmint-18.1-cinnamon-32bit.iso" of=/dev/sdb

NOTE: fdisk for the most part is considered (! note that it's considered, although still can be used) deprecated. Recommended alternative on most modern OS with GNU utilities is sudo parted -l

$ sudo parted -l
[sudo] password for xieerqi: 
Model: ATA Radeon R7 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  120GB  120GB  primary  ext4         boot
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • Great advice, Serg. Clearly I need to do a bit more research into using ubuntu before I contemplate the switch across, so I can learn the boldlsusbbold and boldpartedbold** commands confidently. Also , as seen in the comment above, I'll need to find a forum other than askubuntu to help me change distros. :-S – Rene Thomas Feb 26 '17 at 17:12
  • @ReneThomas take your time and learn slowly. There's so many things Windows users deal with on daily basis, that they very often take it for granted. I've been full-time Ubuntu user ( and dare I say the words , "amateur developer" ), and I'm still learning something new every day. AskUbuntu isn't a forum, so very extended discussions aren't exactly the format for this site, but if you have a question, feel free to ask any time. The community here is great and supportive, so I do hope that will make your Ubuntu journey more fun :) – Sergiy Kolodyazhnyy Feb 26 '17 at 17:20
1

Fdisk is not going to show you the usb port. Using your fdisk output you can examine the properties such as Disklabel, Size, and Type, to help identify which one might be your USB drive.

More info about the drive can be seen using **parted.**

The command sudo parted -l will show you the information you see using fdisk plus other information such as the Manufacture/Model of the drive. You can associate this with the model of your pendrive.

A typical output of parted:

Model: ATA WDC WD20EARS-00M (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  52.4GB  52.4GB  primary  ext4
 2      52.4GB  105GB   52.4GB  primary  ext4            boot
 3      105GB   126GB   21.0GB  primary  linux-swap(v1)
 4      126GB   2000GB  1875GB  primary  ext4


Model: ATA Crucial_CT1050MX (scsi)
Disk /dev/sdb: 1050GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name    Flags
 1      6291kB  1048MB  1041MB                  Prefix  bios_grub
 2      1050MB  106GB   105GB   ext4            os
 4      106GB   1008GB  902GB   ext4            data
 3      1008GB  1050GB  41.9GB  linux-swap(v1)  swap


Model: Verbatim STORE N GO (scsi)sudo 
Disk /dev/sdc: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

In this case, I know that my Pendrive is the Model Verbatim STORE N GO.

Running this hardware command sudo lshw you can find your usb port of that particular device. In this case I search for the block that contains Verbatim STORE N GO and can use that information to identify the port:

$ sudo lshw | less

The found block:

         *-usb:1
              description: Mass storage device
              product: STORE N GO
              vendor: Verbatim
              physical id: 2
              bus info: usb@2:1.2
              logical name: scsi8
              version: 1.00
              serial: 07A904096F83C331
              capabilities: usb-2.00 scsi emulated scsi-host
              configuration: driver=usb-storage maxpower=200mA speed=480Mbit/s

In the lshw output the physical id is the usb port number. The port number will be consistent with the physical USB port were the device is plugged. In this case my Verbatim pendrive is plugged into port #2 of the seven usb ports I have on the particular machine.

Note:
A fail-safe way to verify I'm using the right USB port is to umount the usb drive then unplug it. Then plug it back in and notice the new drive specification that appears.

L. D. James
  • 25,036
  • Thanks for giving me such comprehensive advice, L.D James. I am sure to take all that on board, in combination with the other answers and comments. It might take me a while, though, as it's is a lot for a beginner like me to digest, especially with me having limited time to concentrate on learning Linux. I can see your own knowledge of it is most impressive, as is your kindness in taking such time to provide an in-depth tutorial like the above. – Rene Thomas Feb 26 '17 at 17:18
  • You're very welcome. We are available to assist you with your problems. I understand it might appear overwhelming and complicated. You shouldn't use dd, a pretty advance tool. We responded directly to your question. The install is very easy and seamless. Just create an Ubuntu install disk. Download the iso from the official site. Burn the ISO. Then boot to it and follow the GUI prompts, detailed here. – L. D. James Feb 26 '17 at 17:38
  • @ReneThomas Reviewing your question, I might have misunderstood the intentions of your comment above. My response was my normal mode of giving assistance to problems with Ubuntu. If you are not trying to install Ubuntu, you can disregard the install steps. Revisit the steps if you decide again to install Ubuntu. – L. D. James Feb 26 '17 at 17:45