24 December 2019

Ubuntu Server USB WritableIf you use Ubuntu Desktop, using a USB stick is a piece of cake. You just plug it in, read/write files, and yank it out again.

But what about Ubuntu Server?

Try the same thing, and you end up with a USB stick that can only be accessed by root. Well, that’s probably not what you want!

There are several ways to solve this problem, but by far the easiest – believe it or not – is to add a touch of Windows…

Why the heck would you do that?

Why would I need a world-readable/writable USB stick when using Ubuntu Server?

Well, backups, for one. Cheap USB stick, removable media, and the backup files should be accessible from any OS – including my Windows puter.

If I need data security, I can encrypt or otherwise password-protect the archives.

Also, this trick is pretty handy if you have a shared drive via samba that acts as file storage for Windows machines on your local network.

No, I meant: Why use a bit of Windows with linux?!

Oh, that’s easy: Because it Just Works.

So, without further ado:

1. Install the package ntfs-3g like so:

sudo apt install ntfs-3g

2. With your USB stick plugged in, find its path by typing:

df -h

3. We’ll assume your USB stick is /dev/sdc1 for this example. Next, format the USB stick with NTFS like so:

sudo mkntfs --fast --label USBbackup /dev/sdc1

4. Find the UUID of your USB stick by typing blkid and search for /dev/sdc1 in the list

5. Finally, add the following line to /etc/fstab:

UUID=4C2B3FA56C9AE701 /media/backup ntfs-3g defaults,noatime,uid=1000,umask=000,locale=en_US.utf8 0 0

Ta-DA!  Note that the UUID and path (/media/XXXX) will be different in your case.

Now, you can just leave the USB stick in the server, and it will remount automagically on reboot.

What’s more, the owner of the USB stick is the default ubuntu user (uid=1000), with group root. And permissions are 777 – IOW, any user can read/write to the stick (umask=000). The noatime parameter ensures that the file/directory timestamps won’t be updated on every file access – which is good for performance and flash endurance.

Because the USB stick is formatted as NTFS, you can yank it out and stick it in your Windows puter and read the files without a problem!

What about a shared samba NTFS drive?

Ah yes… If you’re doing this for a shared hard drive on your local network instead of a USB stick, you can make the newly-formatted NTFS drive accessible on the network by adding the following to /etc/samba/smb.conf:

[shared]
  comment = Backup Folder
  path = /media/backup/
  available = yes
  browseable = yes
  read only = no
  public = yes
  writable = yes
  create mask = 0777
  directory mask = 0777
  guest ok = yes
  force user = nobody
  force group = nogroup
  wide links = yes
  follow symlinks = yes

Note that the name of the share ([shared] in this case) can be changed to whatever you want.  You’ll probably also want to change the path.

Voila! You can now access your Ubuntu Server’s NTFS shared disk from any Windows or linux machine.

No more permissions headaches.

Just keep in mind that if security is a must, you probably don’t want to use this method. Or, just encrypt everything before you stick it on the USB/shared drive!

Looking for a fast USB stick? Watch: Fast USB 3 sticks that won’t break the bank

Get Scottie Stuff!
Help! My USB stick is read-only in Ubuntu Server
Tagged on:                 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.