0

I just bought a brand new Dell Inspiron 3185 with a massive 1.6 GHz dual-core AMD Radeon R4, a whopping 32gig SSD and a mind boggling 4 gigs of memory; a veritable rocket marked down from AUD $380 to AUD $180. It came with Windows 10 but it started bitching about space so I dumped it and have now installed Ubuntu. I spent the day reading about Bitcoin and I want to install bitcoin core but there is not enough space in my root directory to store the blockchain ledger so I have decided to download it onto a SD Card that I leave there permanently and for beauties sake I want to have it mounted on /opt.

I have found out how to disable automount and I can mount the drive on /opt manually but I can't find a post about how to change the automatic mount point for a drive named opt from /media/opt to /opt. Is there somewhere that I can place a script that would have this effect? How about you post yours as an example.

I know it's a waste of time but I'm on a pension and I have plenty to waste, the last time I played with Linux it took me a whole day to get Debian to automount a CDROM and something like three months of weekends to configure a 486 router with ipmasquerade, ipchains, dhcpd and sshd; apt-get was a nightmare too. It was before Gnome and you had to configure the X11 Server and set up a Window Manager manually, I got Window Maker going on my Pentium II but I never used it much and I didn't bother with X11 for the router.

I'll mess around with bitcoin core's configure script as a starting point and to try to work out how to get it to download the ledger into /opt and with a bit of luck someone will have given me a tip-off about this problem by the time I am ready to sync my wallet.

It should keep me busy for quite a while, I just need to build up a head of steam. Sort the right click on my mouse pad out, then finish this bitcoin book, then work out Open VPN, then a few books on the Tor, maybe I'll splash out and get an i7 desktop that can run Virtual Box and play a few games if I'm still chugging along after that.

First things first, the I/O won't be brilliant but how do I mount this little sucker on bootup.

Linux again, it's come a long way.

  • 2
    Automated mount points are handled by /etc/fstab typically. However, you should be careful when mounting to /opt/ because any programs installed to the external drive mounted there will cease to function whenever the disk is not connected. Depending on what all is installed there (and some third party packages install there!) it could cause problems in the longer term with the system. – Thomas Ward Oct 31 '18 at 13:52
  • 1
    you could mount the Bitcoin app data in /opt/bitcoin-core/ or such and bind your opt drive to /opt/bitcoin-core directly, but if Bitcoin is autostarting it'll explode when the drive isn't connected. – Thomas Ward Oct 31 '18 at 15:41
  • I was thinking that nothing would use it except the bitcoin app but fair enough it's not a good idea, judging from the comments it does get used. I just read that it originated in the early days of UNIX when a disk would "optionally" get mounted there to supplement /usr/local. There is a slot for an SD Card, I could just stick one in and never take it out to prevent an "explosion". – Routebee Oct 31 '18 at 15:52

2 Answers2

1

Do not do this!

/opt/ is one of the Ubuntu system folders. This means Ubuntu expects this folder be available at all time. Mounting an external USB drive as /opt means that when the SD Card/USB drive is not connected the /opt/ folder will not be available to the system.

Many third party applications like bitcoin core, and Google Chrome, are installed in the /opt/ folder. If you lose your USB drive or if the USB drive breaks, or gets corrupted then the third party apps won't run and system may not work as intended. For example, if you set up bitcoin core to run at startup, that won't work.

Now that you have been warned, lets do this!

How to use external SD card as /opt system partition

Choose a reliable drive

You may want to use a SSD based USB rather than an SD card if you want a reliable and fast drive that is less likely to die on you. I suggest you look for SSD based USB 3.0 drives. The SSD based drives are more reliable than the run off the mill USB drives. USB 3.0 (or better) drives allow faster input and output provided your computer has an USB 3.0 port.

Format the SD card/USB drive

This SD card/USB drive should be dedicated for /opt partition. That is you should not use it for anything else. Since you want to use it as a system partition, the partition must be formatted in a way that allows Ubuntu to use it as such. In particular, the partition format must allow for setting file ownership, permissions, and executable settings for the files in this partition that Ubuntu can handle. Windows partition formats such as FAT32 and ntfs do not normally handle these things in Ubuntu friendly manner.

Open gparted (install it if needed) with the SD card/USB drive plugged in, and navigate to the SD card/USB drive using the top right drop down list of drives.

Unmount the single partition. Format the single partition in the SD card/USB drive as ext4. This is the default partition format for Ubuntu and is needed for Ubuntu system folders such as /opt/. You may be able to use ext2 or ext3 formats, but FAT32 or ntfs are not recommended.

Apply the changes you have made in gparted.

Use the gparted menu to go to Partition > Information and note down the UUID of the partition you created in the SD card/USB drive.

Exit the gparted program.

Alternately use the command line:

Open a terminal using Ctrl+Alt+T and enter:

df -h

This will list all the partitions. Identify the SD Card/USB drive. I will assume it is /dev/sdb1. You may have something different.

Use the following command to unmount the partition. A partition must be unmounted before formatting.

sudo umount /dev/sdb1

Use the following command to format the partition.

sudo mkfs.ext4 /dev/sdb1

Note: Even though we want to format the whole drive, we don't use /dev/sdb. In this case the first partition spans the whole drive.

Setup /etc/fstab to mount the partition at boot

I am not sure you can change the automount config so that it works one way for a specific SD card/USB drive but differently for all otherSD cards/USB drives.

The automount is primarily for removable media such as a SD card/USB drive, so that these are mounted automatically when they are inserted. Since we want the /opt partition to be permanently mounted at boot time, rather than mounted when inserted, I think editing the fstab is the right approach.

Open a terminal using Ctrl+Alt+T and enter:

sudo nano /etc/fstab

This will open the file fstab in the /etc/ folder using the nano editor. You will be prompted for your password. When you enter the password, nothing will happen in the terminal. The cursor will not move, you will not see any stars. This is normal.

Add a new line in /etc/fstab that will look like:

UUID=ABCD-MNOP /opt    ext4    defaults        0       2

where ABCD-MNOP is the actual UUID of the partition inside the SD card/USB drive you have copied in the step above.

To save the changes and exit nano, use Ctrl+X followed byY and Enter.

Use the following command to mount the new /opt partition:

sudo mount -a

If you don't see any errors your /opt partition is mounted correctly.

Reboot the computer and use gparted to double check that the /opt partition is mounted after reboot.

Never ever unplug this SD card/USB drive!

Hope this helps

user68186
  • 33,360
  • I mean whatever application detects the addition of new media and mounts it automatically; I think it was once called automount. Back in the 90's I remember having the problem of CD's automatically mounting when you inserted them but then having to manually umount in order to eject. – Routebee Oct 31 '18 at 17:09
  • Thanks for that clarification. Now I understand your question better. I have edited my answer to distinguish between automount removable media and change fstab to automatically mount a disk at boot time. – user68186 Oct 31 '18 at 17:34
  • I'd give you both an up vote but my reputation is not high enough. I'll use an SD Card because a USB would get mauled in a bag and I'll just use mkfs -t ext4 /dev/sdb# and format the whole thing rather than use a partitioning tool. Are you sure there will be no conflict with automount (or whatever it is called) trying to mount the media a second time. And so what if it did for that matter, It would just be a error message that you would never see on runlevel 3 behind Xwindows. – Routebee Oct 31 '18 at 17:46
  • It will be a primary partition. Assuming the SD card has only one partition, it will be /dev/sdb1. See https://askubuntu.com/questions/22381/how-to-format-a-usb-flash-drive – user68186 Oct 31 '18 at 18:02
-1

If I understand this correctly your USB-drive is named opt. On my system /opt is being used by other programs (ex. TeamViewer config files), so if you mount a USB drive to /opt these config files would be written to your USB drive, and maybe only work with the USB-drive connected. I would not recommend mounting the drive to this folder, as this is a system folder.

The easiest way would be to let it mount to /media and create a symbolic link to your destination: https://www.cyberciti.biz/faq/creating-soft-link-or-symbolic-link/

$ ln -s {source-filename} {symbolic-filename}

I don't have the bitcoin-core wallet installed but according to this link: https://en.bitcoin.it/wiki/Data_directory The data directory is located at: /home/yourusername/.bitcoin/

So you could link your USB to that wallet using

ln -s /media/opt /home/yourusername/.bitcoin

Where "your username" is the username you log in with.

But if there already exists data in this folder you would have to remove the existing directory before creating the link. This will also remove the wallet.dat which holds your wallet private key, so if you have any funds in your wallet backup the wallet before experimenting. Hope this helps :)

ThunderBird
  • 1,955
m-momr
  • 1
  • 3
  • I'm loving it! It's like Windows except you don't have to live with chronic glitches and the fear of viruses. I was expecting to spend 3 hours editing config files to fix the right mouse button thing but after reading three pages it turns out it was intentional; a double finger tap has replaced the right corner click and the package gnome-tweaks had a GUI option to set it back to the old system. The new system is better than Windows, you don't get a right click menu when you left click and the scroll function works as well. – Routebee Oct 31 '18 at 15:15