LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-16-2021, 11:20 AM   #1
pathfinder027
LQ Newbie
 
Registered: Jan 2021
Location: Virginia Beach, VA USA
Distribution: Linux Mint
Posts: 1

Rep: Reputation: Disabled
How to add a Linux partition to a USB thumb drive?


I just got the 2018 Sixth Edition of the book, _Linux in Easy Steps_, and on pages 22-23 it suggests using a USB memory stick ("thumb drive") as a backup medium. I deleted all the Windows files from a 64GB Patriot thumb drive, but it still has the Windows file system on it. When I tried to back up Linux to it I got the message, "Selected device does not have Linux partition."

How do I add a Linux partition to the USB memory stick?
 
Old 01-16-2021, 11:30 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by pathfinder027 View Post
I just got the 2018 Sixth Edition of the book, _Linux in Easy Steps_, and on pages 22-23 it suggests using a USB memory stick ("thumb drive") as a backup medium. I deleted all the Windows files from a 64GB Patriot thumb drive, but it still has the Windows file system on it. When I tried to back up Linux to it I got the message, "Selected device does not have Linux partition."

How do I add a Linux partition to the USB memory stick?
You can just use a partitioning utility to do it, there are several of them available. Gparted is a popular utility, and it can also format a newly created partition with a filesystem too (including both Linux and windows filesystems).

How exactly are you trying to "back up Linux to it" though? As you would normally use a program to backup an operating system rather than just copying the files manually.
 
Old 01-16-2021, 12:05 PM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,556
Blog Entries: 19

Rep: Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444
A lot of the memory sticks you buy these days aren't partitioned at all. They just have one single Windows FAT32 filesystem stretching across the whole drive. There are about three different ways that I can think of to back up onto a drive like that:

1) jsb's suggestion. Use gparted to create a partition table on the stick and make one or more linux partitions on it. This is the most flexible solution. For example, you could use one of those partitions for a periodic backup of your system and another for day-to-day data file backups.
2) Use the mkfs.ext4 program to turn your unpartitioned stick into a single Linux filesystem which you can then dump onto. This is a bit more dangerous because you have to be very sure you are formatting the stick and not any part of your hard drive. In Linux as in Windows, formatting destroys data!
3) Use the modprobe command to load the vfat driver into your kernel. You should then be able to copy onto your stick as is. This is probably the safest way, but tiresome as you have to do it each time you make a copy.

Last edited by hazel; 01-16-2021 at 12:07 PM.
 
Old 01-16-2021, 12:27 PM   #4
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,473

Rep: Reputation: Disabled
It'll likely make your learning a bit easier if you put an ext4 file system onto it.

(You can save some extra MBs by using the -m option when creating it, I use -m0 for small drives.)
 
Old 01-17-2021, 09:01 AM   #5
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by hazel View Post
A lot of the memory sticks you buy these days aren't partitioned at all. They just have one single Windows FAT32 filesystem stretching across the whole drive. ...
While I know floppy disks don't have partitions; I don't honestly buy the argument that "some USB sticks don't have partitions at all". Surely there would still be at least one partition that, in that case, covers the whole drive. How would you format a USB drive with a filesystem that isn't partitioned? I don't see how you would able to.
 
Old 01-17-2021, 09:02 AM   #6
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,556
Blog Entries: 19

Rep: Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444
Quote:
Originally Posted by jsbjsb001 View Post
How would you format a USB drive with a filesystem that isn't partitioned? I don't see how you would able to.
You format /dev/sdb or whatever.
 
Old 01-17-2021, 09:27 AM   #7
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,340

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by hazel View Post
You format /dev/sdb or whatever.
Remember that /dev/sdb is the device. /dev/sdb1 would be the partition.

I have never seen a flash drive that did not have a partition. Yes, they usually have a single vfat partition, but always have a partition when purchased new.

@pathfinder027
As was said before, partitioning can be done with any of the partitioning tools, and gparted is the gui version of parted. You probably have parted, fdisk, and possibly gdisk available with a new install. gparted may need to be installed. Any of those can be used to change the partition type from msdos to linux.
Gparted can also do the formatting as ext4 or you can use mkfs.ext4 to format it for you. Remember, the partition (ie. /dev/sdb1) is what needs to be formatted, not /dev/sdb.
 
Old 01-17-2021, 09:29 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,669

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
I have not purchased a USB drive without being partitioned in awhile and can not say that it is still true but yes as an example Imation which no longer exists sold flash drives without partitions. They mounted on both linux and Windows without any problems.

We expect a drive to be partitioned by convention and for various reasons but it does not matter. I know formatting ext filesystems actually reserves the first sector so that grub can be installed without a partition table. Totally unrelated but DVRs in the early days wrote video data to an unformatted raw disk for performance.
 
Old 01-17-2021, 09:39 AM   #9
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,556
Blog Entries: 19

Rep: Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444
It's easy to find out one way or another. Plug in your device and look at dmesg|tail. If it reports both sd? and sd?1, there is a partition table on the device. If only sd?, there isn't.
 
Old 01-17-2021, 09:40 AM   #10
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by computersavvy View Post
...
I have never seen a flash drive that did not have a partition.
Same here.

Quote:
Yes, they usually have a single vfat partition, but always have a partition when purchased new.
...
That's always been the case as far as I've seen.
 
Old 01-17-2021, 09:43 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,556
Blog Entries: 19

Rep: Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444Reputation: 4444
I just plugged in the most recent one I bought and it says:
Code:
[19333.398840] scsi 2:0:0:0: Direct-Access     hp       v212w            8.07 PQ: 0 ANSI: 4
[19333.400676] sd 2:0:0:0: [sdb] 30871552 512-byte logical blocks: (15.8 GB/14.7 GiB)
[19333.401423] sd 2:0:0:0: [sdb] Write Protect is off
[19333.401429] sd 2:0:0:0: [sdb] Mode Sense: 23 00 00 00
[19333.402119] sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[19333.414144]  sdb:
[19333.418434] sd 2:0:0:0: [sdb] Attached SCSI removable disk
See? No partition table on that one.
 
Old 01-17-2021, 11:12 AM   #12
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by hazel View Post
You format /dev/sdb or whatever.
It is possible.
I just did
Code:
mkfs.ext4 /dev/sde
on a USB stick. Or fat.
And it's usable.
I've also created encrypted USB sticks like this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying ISO to thumb drive using 'dd' causes thumb drive to be read-only? ahc_fan Linux - General 8 01-15-2019 08:10 AM
dd to copy a thumb drive which I am live booted on to another thumb drive DrinkinHomeBrew Linux - Newbie 3 01-26-2015 04:52 PM
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 8 01-16-2012 12:09 PM
linux only recognizes one partition on a dual-partition thumb drive Jyneo Linux - Hardware 1 09-26-2007 03:12 PM
USB drive using different partitions (usb key thumb drive) Arodef Linux - Hardware 0 08-04-2004 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration