GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD

Wed Sep 12, 2018 10:27 am

An update

I purchased a 1 TB USB HDD that can connect directly to my Pi (similar to one suggested in another thread).

I copied my SD card onto it using the copier in Raspbian then powered Pi and removed the SD card, I then connected the HDD to Pi and powered it up and it booted.

So far so good, I then used gparted to view the partitions on the HDD and noted that there were 2 as expected (boot & rootfs).

Using gparted I then attempted to reduce the size of of rootfs so that I ended up with 900GB of unallocated partition (Original disc size 931.78 GB so boot and rootfs occupied 31.78GB).

I next rebooted Pi and it would not load, I just got pages of messages all starting with "Failed" plus data afterwards.

I surmised that by resizing the rootfs partition I lost data hence the errors.

I then created partitions of 31GB (EXT4) and 900GB (NTFS), download the latest version of stretch and using Etcher wrote it to the 31Gb partition, when I connected the HDD to Pi it started to boot then stopped at the raspberries screen and went no further. I appears that Raspbian will not share a drive with anything else.

I have tried numerous methods to get Pi to boot from the HDD without Raspbian occupying the whole 1TB of the HDD.

Getting to the question now which is; has anybody had any experience of booting a Pi from a HDD partiton and using the same HDD as a storage device ie simply making the HDD appear as 2 HDDs?

The moving Pi home to the HDD is now on the back burner while I explore this method.

As a footnote I found that Pi detected the HDD (a WD Elements 1TB external drive powered from the USB port) and booted from it without me having to change a single thing in the stretch download (no boot bin on an SD card) so the progress by the RPF in this area is to be commended.

ejolson
Posts: 2159
Joined: Tue Mar 18, 2014 11:47 am

Re: Move Pi home from SD card to a HDD

Wed Sep 12, 2018 12:05 pm

GAP wrote:
Wed Sep 12, 2018 10:27 am
I surmised that by resizing the rootfs partition I lost data hence the errors.
Raspbian mounts the root filesystem using a partition UUID which likely changed when you resized the partition. If so, this would explain why the system didn't boot afterwards.

One solution is to give the root partition a label such as RASPIAN and then change /boot/cmdline.txt to specify root=LABEL=RASPBIAN. Another solution would be to update the root= directive with the changed UUID.

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD

Thu Sep 13, 2018 9:18 am

If I load Raspbian and let it take over my 1TB HDD (which it does) I can then boot from it and I have my Desktop and a massive Documents folder on my HDD instead of an SD card - Yes/No?

If I connect a 2nd HDD to my Pi formatted as NTFS, which will show as a mounted HDD in media/Pi, I can then view/access it from my XP machine using Samba. I have now overcome the limits of using an SD card read/write wise - Yes/No?

I believe that if I pursue this scenario I should end up with a fully functional Pi desktop machine am I correct - Yes/No?

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Move Pi home from SD card to a HDD

Thu Sep 13, 2018 10:21 am

Hi there! Glad you're back!
GAP wrote:
Thu Sep 13, 2018 9:18 am
If I load Raspbian and let it take over my 1TB HDD (which it does) I can then boot from it and I have my Desktop and a massive Documents folder on my HDD instead of an SD card - Yes/No?
Yes, the /home/pi/Desktop and /home/pi/Documents resides on the boot HDD. Actually its made to be there by default during installation. You can check it out using the file manager, and start moving your files there.
GAP wrote: If I connect a 2nd HDD to my Pi formatted as NTFS, which will show as a mounted HDD in media/Pi, I can then view/access it from my XP machine using Samba. I have now overcome the limits of using an SD card read/write wise - Yes/No?
another Yes. Actually I've been doing the same thing on my torrent box. It has 2 NTFS formatted HDDs shared to the network via samba. Windows, Mac, Android, and other Linux OS can see and access the 2 HDDs.

for others who started reading from this point, make sure you install ntfs-3g to have full access to the NTFS formatted HDDs
GAP wrote: I believe that if I pursue this scenario I should end up with a fully functional Pi desktop machine am I correct - Yes/No?
Speaking from my experience with this RPi3B+ (and the RPi3B before this), its a Yes from me. (others may have different view on the matter)

Once you've completed your preferred setup, and copying of your important data... do remember to make an image backup of the system on the HDD boot drive. I think we've covered the procedure for that in our previous discussions....
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 3:14 am

I'm just giving up and going along with the above method of using the HDD like its a big SD card.
Raspbian just takes over my HDD like a virus and no matter what I try I can't stop it.
Time to admit defeat its just not worth the angst anymore.

ejolson
Posts: 2159
Joined: Tue Mar 18, 2014 11:47 am

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 4:16 am

GAP wrote:
Fri Sep 14, 2018 3:14 am
I'm just giving up and going along with the above method of using the HDD like its a big SD card.
Raspbian just takes over my HDD like a virus and no matter what I try I can't stop it.
Time to admit defeat its just not worth the angst anymore.
Sometimes, especially with computers, it's good to take a break. Sometimes the problem seems much easier a year later: the technology improves as does ones understanding.

Having said this, I think it is possible to edit cmdline.txt before first boot and remove the option that causes Raspbian to resize the partition to take over the entire disk. At this point, however, it is probably best to work on something else.

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 10:34 am

ejolson wrote:
Fri Sep 14, 2018 4:16 am
GAP wrote:
Fri Sep 14, 2018 3:14 am
I'm just giving up and going along with the above method of using the HDD like its a big SD card.
Raspbian just takes over my HDD like a virus and no matter what I try I can't stop it.
Time to admit defeat its just not worth the angst anymore.
Sometimes, especially with computers, it's good to take a break. Sometimes the problem seems much easier a year later: the technology improves as does ones understanding.

Having said this, I think it is possible to edit cmdline.txt before first boot and remove the option that causes Raspbian to resize the partition to take over the entire disk. At this point, however, it is probably best to work on something else.
It is working like this;
The Pi boots off the HDD and I have loads of space for documents and desktop both of which ar accessible from the XP via the ethernet cable using samba.

I have connected a 2nd 1TB HDD again accessible from XP, attached to XP is a 500GB HDD plus there is its internal HDD so I now have so much storage I should never fill it up.
Its just now a matter of accessing the XP HDD from Pi I had that working before.

Until I gain more experience (like how to edit text line) with Pi and can get some Pi time I will run like this.

Thank you to all who have offered suggestions and help it was much appreciated even if I did end up just quitting to take a breather and get the frustration under control.

For future people who may read this the HDD is a WD elements running straight off the USB port and Pi mounted it automatically straight out of the box with no changes to software at all.

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 10:53 am

Glad you had your RPi booting from HDD (though not as you hoped it should behave), and attached a working 2nd HDD.

I might try this weekend doing a HDD split for the boot drive (I think this is what you wanted, 3 partitions /BOOT, /, and [my partition]) and see if it will work or "will kick the bucket"....
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

BlackKnight_UK
Posts: 71
Joined: Mon Jan 02, 2017 10:51 am

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 10:58 am

I wish I could remember what I did. On my Pi2 I wanted to do the same thing, put the home folder on an external drive, I did that and got it working then realized I could put the whole OS on the external drive.

k-pi
Posts: 646
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Move Pi home from SD card to a HDD (Given up)

Fri Sep 14, 2018 1:39 pm

To have your /home on an external drive, you only have to add it to /etc/fstab.

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Move Pi home from SD card to a HDD (Given up)

Sun Sep 16, 2018 9:11 am

Well it is weekend so I tried something that I posted that I will do, "HDD split" for the boot HDD drive.

If raspbian is flashed to USB device (from here on will use "HDD" as USB device) using Etcher, even if the HDD is partitioned to 2 (or 2+n) parts, Etcher will delete all partitions and flash raspbian into 1 big single partition. The HDD has a capacity of 250GB

Proceeded with installing raspbian on that one big partition. The RPi used in this test installation is an RPi3B
Once the initial raspbian installation was finished, proceeded to installing my favorite packages/apps.

So I still have one big partition on the 250GB HDD. But I want to have the root partition to be smaller (say about 100GB ).

Shutdown RPi3B, unplugged the HDD and plugged it into another RPi (RPi3B+ with a 32GB USB flashdrive boot).
***This can be substituted by using a microSD card with an installed raspbian desktop on the RPi3B***
Once the HDD was mounted, used gparted to unmount and shrink the root partition on the HDD to just about 97GB.
The remaining space in the HDD was left as un-allocated space (not formatted)
After the shrinking process was completed, exited gparted, unplug the HDD from RPi3B+ and plugged it again to RPi3B.

Powered up the RPi3B... it booted! Yay!
So my RPi3B booted on a shrunk root partition of the HDD. I was expecting it not to, but good thing it did.

Next I opened gparted on the RPI3B and formatted the remaining un-allocated space in the HDD to NTFS format.
After the format process was completed, exited gparted and issued reboot command.

Aaaaaand it rebooted without any problems! Success! "HDD split" is possible!

below are some of command outputs after the process.

Code: Select all

[email protected]:~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0  43.2M  0 part /boot
├─sda2   8:2    0  97.3G  0 part /
└─sda3   8:3    0 135.5G  0 part /media/pi/mypartition

Code: Select all

[email protected]:~ $ blkid
/dev/sda1: LABEL="boot" UUID="6228-7918" TYPE="vfat" PARTUUID="51301da5-01"
/dev/sda2: LABEL="rootfs" UUID="6bfc8851-cf63-4362-abf1-045dda421aad" TYPE="ext4" PARTUUID="51301da5-02"
/dev/sda3: LABEL="mypartition" UUID="641102156BE01A4D" TYPE="ntfs" PTTYPE="dos" PARTUUID="51301da5-03"
Next is how to direct raspbian to change the path of home directory from /home to /media/pi/mypartition/home
This one I need help with
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

epoch1970
Posts: 2126
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Move Pi home from SD card to a HDD (Given up)

Sun Sep 16, 2018 4:43 pm

LTolledo wrote:
Sun Sep 16, 2018 9:11 am
Next is how to direct raspbian to change the path of home directory from /home to /media/pi/mypartition/home
This one I need help with
Briefly and untested, as I do not have a Stretch machine installed ATM:
- I'm not certain an NTFS system can hold a unix user home directory? Perhaps an ext4 partition is preferable. In this case the question is moot.
- /media is supervised by the system which plays with access rights (and namespaces), it is better to use a custom mountpoint to avoid such interferences, such as /mnt/mydrive

This being said, I see 3 ways of doing it, in theory:
1 - You could run usermod (or some user administration utility) and change the homedir of user Pi to the new home and copy its contents. ~pi will point to the external drive once you login/logout (try logging in from another window, don't logout completely from the machine!)
2 - You could replace /home/pi with a symbolic link pointing to /mnt/mydrive/pi
3 - You could "bind mount" /mnt/mydrive/pi to /home/pi. Apparently ntfs3g handles bind mounts.
First one is the simplest and should work. Second one is rather bad, if the drive is not here the homedir will be missing, making login impossible. Third one is fancy: you could keep your current /home/pi directory contents and remount /mnt/mydrive/pi on top of it, masking the original contents; login using the original contents of /home/pi should be by and large possible even if the external drive is missing.

That is for the theory. In practice, systemd and its parallel mounting procedure might give you a hard time with bind mounts. For my part on Jessie machine I gave up on using fstab for bind mounts, and went with autofs5 direct mounts to handle them.

My recommendation would be to see if moving $HOME with usermod is enough, and if not to create an extra ext4 partition and mount it to /home/pi.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

ejolson
Posts: 2159
Joined: Tue Mar 18, 2014 11:47 am

Re: Move Pi home from SD card to a HDD (Given up)

Sun Sep 16, 2018 6:53 pm

epoch1970 wrote:
Sun Sep 16, 2018 4:43 pm
LTolledo wrote:
Sun Sep 16, 2018 9:11 am
Next is how to direct raspbian to change the path of home directory from /home to /media/pi/mypartition/home
This one I need help with
I'm not certain an NTFS system can hold a unix user home directory?
You are right NTFS does not work for home directories. The simplest solution is to leave home where it is and create a symbolic link to make accessing the NTFS partition easier. For example,

$ cd
$ ln -s /mnt/mydrive mydrive

This will make a shortcut in your home directory that takes you to the NTFS partition.

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD

Wed Sep 19, 2018 6:49 am

LTolledo wrote:
Sun Sep 16, 2018 9:11 am
Well it is weekend so I tried something that I posted that I will do, "HDD split" for the boot HDD drive.

If raspbian is flashed to USB device (from here on will use "HDD" as USB device) using Etcher, even if the HDD is partitioned to 2 (or 2+n) parts, Etcher will delete all partitions and flash raspbian into 1 big single partition. The HDD has a capacity of 250GB

Proceeded with installing raspbian on that one big partition. The RPi used in this test installation is an RPi3B
Once the initial raspbian installation was finished, proceeded to installing my favorite packages/apps.

So I still have one big partition on the 250GB HDD. But I want to have the root partition to be smaller (say about 100GB ).

Shutdown RPi3B, unplugged the HDD and plugged it into another RPi (RPi3B+ with a 32GB USB flashdrive boot).
***This can be substituted by using a microSD card with an installed raspbian desktop on the RPi3B***
Once the HDD was mounted, used gparted to unmount and shrink the root partition on the HDD to just about 97GB.
The remaining space in the HDD was left as un-allocated space (not formatted)
After the shrinking process was completed, exited gparted, unplug the HDD from RPi3B+ and plugged it again to RPi3B.

Powered up the RPi3B... it booted! Yay!
So my RPi3B booted on a shrunk root partition of the HDD. I was expecting it not to, but good thing it did.

Next I opened gparted on the RPI3B and formatted the remaining un-allocated space in the HDD to NTFS format.
After the format process was completed, exited gparted and issued reboot command.

Aaaaaand it rebooted without any problems! Success! "HDD split" is possible!

below are some of command outputs after the process.

Code: Select all

[email protected]:~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0  43.2M  0 part /boot
├─sda2   8:2    0  97.3G  0 part /
└─sda3   8:3    0 135.5G  0 part /media/pi/mypartition

Code: Select all

[email protected]:~ $ blkid
/dev/sda1: LABEL="boot" UUID="6228-7918" TYPE="vfat" PARTUUID="51301da5-01"
/dev/sda2: LABEL="rootfs" UUID="6bfc8851-cf63-4362-abf1-045dda421aad" TYPE="ext4" PARTUUID="51301da5-02"
/dev/sda3: LABEL="mypartition" UUID="641102156BE01A4D" TYPE="ntfs" PTTYPE="dos" PARTUUID="51301da5-03"
Next is how to direct raspbian to change the path of home directory from /home to /media/pi/mypartition/home
This one I need help with
That procedure is what I have been trying with no luck.
I was given the same procedure from another Pi user and it worked for him as well.
When I try to unmount the sda partitions I get "cannot unmount this partition" it was at this point I just gave up previously

To clarify what I have done is;
Power down Pi install the SD card that I copied onto the HDD and started up Pi.
Then went to gparted and tried to unmount the partitions on sda (the HDD) which is where I get the error messages.
Where am I going wrong with this is it because I am using the same Pi (only have one)?

Also I now have a 160GB SATA 2.5" HDD that I can copy my SD card to but when I try to start Pi off it it will not boot.
I think I am back to my old problem of the HDD not spinning up fast enough.
Going back over old ground here but I seem to remember a one liner of add a delay line in a cmd.txt file.
I am willing to try this but have so far not been able to find which command to use.

A step by step instruction on how to do that would be marvellous.

EDIT; I have had this recommended to me by a member on my model train forum who is also using a Pi to control his layout which is my ultimate goal.
sudo nano /boot/cmdline.txt and add rootwait text to the line.

Only problem is that when it come to nano I struggle badly, Leafpad works for me so I will use that.

Recommended
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait text splash plymouth.ignore-serial-consoles

My current
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=93a87dd1-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quietsplash plymouth.ignore-serial-consoles

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Move Pi home from SD card to a HDD

Wed Sep 19, 2018 10:06 am

GAP wrote: .... install the SD card that I copied onto the HDD and started up Pi.
I think this may be the cause of the problem.

can you try booting your one-and-only RPi3B+ using a microSD with freshly installed raspbian stretch with desktop.

once booting is finished, install gparted. dont need to update or upgrade at the moment (its only a temporary installation, but you may keep it if you want to.)

then plug in the USB HDD that you want to split. you should be able to unmount the plugged HDD and split it now in gparted.

below is the cmdline.txt from the HDD split setup: (3.5" 250GB HDD in 12v self powered SATA to USB 2.0 HDD case)

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=51301da5-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
below is the fstab:

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=51301da5-01  /boot           vfat    defaults          0       2
PARTUUID=51301da5-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
as you can see the other part of the split is not mounted via fstab

however when I check via lsblk and df -h
~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

Code: Select all

sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0  43.2M  0 part /boot
├─sda2   8:2    0  97.3G  0 part /
└─sda3   8:3    0 135.5G  0 part /media/pi/mypartition

Code: Select all

~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        96G  3.6G   89G   4% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   13M  452M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/sda1        43M   22M   21M  52% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/sda3       136G   69M  136G   1% /media/pi/mypartition
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD

Thu Sep 20, 2018 10:18 am

Been thinking about this and I now have a huge headache. ;)

If/when I manage to shrink the partition and effectively create a desktop computer with a HDD similar to what I would have ended up with if I had just bought a Win machine; is it possible to have the left over partitioned to act as if it is an external HDD?

Ideal scenario is to have a the HDD partitioned as home and an NTFS partition that will appear as a separate HDD that I can see from the XP machine is that clear as mud for folks?

Talk about a learning experience (the object of Pi).

I will persevere with this plus as I now have another HDD I will also attempt to get the Pi to boot from it and use one of the 2 1TB HDDs as storage.

Looks like I now have 2 projects running in parallel trying to achieve a similar outcome fun time ahead I think.

Ernst
Posts: 714
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Move Pi home from SD card to a HDD

Thu Sep 20, 2018 10:59 am

I also have a headache trying to understand the problems in this thread and for that reason I have not yet posted.

There is a simple way to reach at least one of your objectives: to have an ntfs partition that can be used under Windows XP as a separate external drive and can be used to boot Raspbian on a Pi with access to the ntfs partition.
Until now I have seen that you have been trying to reduce the root partition, but it might be simpler to increase the size of a partition instead (if needed).

First step is to install the Win32DiskImager on your PC: https://sourceforge.net/projects/win32diskimager/, for Windows XP you may need to download version 0.9 from the files archive.
Then download the unzip utility from http://infozip.sourceforge.net/ and the latest Raspbian release from https://www.raspberrypi.org/downloads/raspbian/, use unzip to extract the image file to your hard disk.
Now use Win32DiskImager to write the Raspbian image to adequate size (32/64G) micro SD card, use this card to boot the Pi, to customize the installation and to get the latest updates with apt-get.
Once completed use Win32DiskImager on the PC to create an image of the SD card in a file on your hard disk, be aware that you will need the same amount space as the size of the micro SD card. Then use Win32DiskImager to write the image to your hard disk, use the Windows Disk Manager to create the NTFS partition, and next boot from this hard disk.
Once booted you have to unmount the ntfs partition and to update the fstab to mount the partition where you need it.

The above is the space consuming method, the alternative is to use Win32DiskImager to write the Raspbian image directly to the hard disk. But then you should edit the file cmdline.txt so that the partition is not extended on the first boot by removing "init=/usr/lib/raspi-config/init_resize.sh". Next you could boot from an micro SD card to increase the root partition on the HDD, and then create an ntfs partition on your PC.
The road to insanity is paved with static ip addresses

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Move Pi home from SD card to a HDD

Thu Sep 20, 2018 11:21 am

GAP wrote:
Thu Sep 20, 2018 10:18 am
If/when I manage to shrink the partition and effectively create a desktop computer with a HDD similar to what I would have ended up with if I had just bought a Win machine; is it possible to have the left over partitioned to act as if it is an external HDD?
So you were able to split/shrink the USB HDD's /root partition in gparted?

the remaining unallocated space in the USB HDD after the split/shrink can be formatted to NTFS(or any format you like), and then shared to the network via samba, so that it can be seen by the winXP unit.

the newly formatted NTFS partition will always be automatically mounted by raspbian, there is no need to edit /etc/fstab (see my post above). You may use it as if its an "externally mounted USB HDD"

if there may be a need for you to plug the (split) USB HDD to winXP, you may be able to see only 2 partitions (volumes), namely /boot and [name of NTFS volume] partitions.
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

ejolson
Posts: 2159
Joined: Tue Mar 18, 2014 11:47 am

Re: Move Pi home from SD card to a HDD

Thu Sep 20, 2018 6:19 pm

Ernst wrote:
Thu Sep 20, 2018 10:59 am
But then you should edit the file cmdline.txt so that the partition is not extended on the first boot by removing "init=/usr/lib/raspi-config/init_resize.sh".
Modifying cmdline.txt before the first boot to prevent Raspbian from taking over the entire disk is what I suggested earlier.

I wonder whether it would be possible for the the NTFS partition to be first and put the Raspbian /boot and /root filesystems at the end of the disk.

GAP
Posts: 125
Joined: Thu Apr 12, 2018 9:18 am
Location: New South Wales Australia

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 7:46 am

@ L Tolledo, I have just tried the gparted shrink partition method using a freshly flashed SD card and it did not work, just got heaps of failed messages and Pi just locked up. It looked as though the boot part worked but roofs just did not.
Ernst wrote:
Thu Sep 20, 2018 10:59 am
I also have a headache trying to understand the problems in this thread and for that reason I have not yet posted.

This thread has drifted so much as I have been thinking about the method of solving this that I am not surprised anybody is confused, perhaps I should start again, its just I really don't know which questions to ask.

There is a simple way to reach at least one of your objectives: to have an ntfs partition that can be used under Windows XP as a separate external drive and can be used to boot Raspbian on a Pi with access to the ntfs partition. This has always been the objective but the thread drift is mostly caused by me as I changed the objective by grasping at straws see above.

Until now I have seen that you have been trying to reduce the root partition, but it might be simpler to increase the size of a partition instead (if needed).

First of all may I just say To do any downloadingI will use my Win 10 machine XP is not allowed to go anywhere near the internet.

First step is to install the Win32DiskImager on your PC: https://sourceforge.net/projects/win32diskimager/, for Windows XP you may need to download version 0.9 from the files archive.

Then download the unzip utility from http://infozip.sourceforge.net/ and the latest Raspbian release from https://www.raspberrypi.org/downloads/raspbian/, use unzip to extract the image file to your hard disk. Is this the external HDD or the one on my Win 10 machine?

Now use Win32DiskImager to write the Raspbian image to adequate size (32/64G) micro SD card, use this card to boot the Pi, to customize the installation and to get the latest updates with apt-get.

Once completed use Win32DiskImager on the PC to create an image of the SD card in a file on your hard disk, be aware that you will need the same amount space as the size of the micro SD card.

Then use Win32DiskImager to write the image to your hard disk (the external HDD?), use the Windows Disk Manager to create the NTFS partition, and next boot from this hard disk (the external HDD?).

Once booted you have to unmount the ntfs partition and to update the fstab to mount the partition where you need it. I will need more information on where to look for/ how to do this please.


The above is the space consuming method, the alternative is to use Win32DiskImager to write the Raspbian image directly to the hard disk. (the external HDD?).

But then you should edit the file cmdline.txt so that the partition is not extended on the first boot by removing "init=/usr/lib/raspi-config/init_resize.sh".
Would I edit the cndline.txt when it is in my Win 10 machine, if so how do I do that? or do I I just used sudo nano cmdline.txt in terminal and got a blank page

Next you could boot from an micro SD card to increase the root partition on the HDD, and then create an ntfs partition on your PC. Sorry I do not understand this.

Sorry about all the questions but I am totally new at this but I am gradually learning bits and pieces.

Ernst
Posts: 714
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 8:33 am

GAP wrote:
Fri Sep 21, 2018 7:46 am
@ L Tolledo, I have just tried the gparted shrink partition method using a freshly flashed SD card and it did not work, just got heaps of failed messages and Pi just locked up. It looked as though the boot part worked but roofs just did not.
Ernst wrote:
Thu Sep 20, 2018 10:59 am
I also have a headache trying to understand the problems in this thread and for that reason I have not yet posted.

This thread has drifted so much as I have been thinking about the method of solving this that I am not surprised anybody is confused, perhaps I should start again, its just I really don't know which questions to ask.

There is a simple way to reach at least one of your objectives: to have an ntfs partition that can be used under Windows XP as a separate external drive and can be used to boot Raspbian on a Pi with access to the ntfs partition. This has always been the objective but the thread drift is mostly caused by me as I changed the objective by grasping at straws see above.

Until now I have seen that you have been trying to reduce the root partition, but it might be simpler to increase the size of a partition instead (if needed).

First of all may I just say To do any downloadingI will use my Win 10 machine XP is not allowed to go anywhere near the internet.

First step is to install the Win32DiskImager on your PC: https://sourceforge.net/projects/win32diskimager/, for Windows XP you may need to download version 0.9 from the files archive.

Then download the unzip utility from http://infozip.sourceforge.net/ and the latest Raspbian release from https://www.raspberrypi.org/downloads/raspbian/, use unzip to extract the image file to your hard disk. Is this the external HDD or the one on my Win 10 machine?

Now use Win32DiskImager to write the Raspbian image to adequate size (32/64G) micro SD card, use this card to boot the Pi, to customize the installation and to get the latest updates with apt-get.

Once completed use Win32DiskImager on the PC to create an image of the SD card in a file on your hard disk, be aware that you will need the same amount space as the size of the micro SD card.

Then use Win32DiskImager to write the image to your hard disk (the external HDD?), use the Windows Disk Manager to create the NTFS partition, and next boot from this hard disk (the external HDD?).

Once booted you have to unmount the ntfs partition and to update the fstab to mount the partition where you need it. I will need more information on where to look for/ how to do this please.


The above is the space consuming method, the alternative is to use Win32DiskImager to write the Raspbian image directly to the hard disk. (the external HDD?).

But then you should edit the file cmdline.txt so that the partition is not extended on the first boot by removing "init=/usr/lib/raspi-config/init_resize.sh".
Would I edit the cndline.txt when it is in my Win 10 machine, if so how do I do that? or do I I just used sudo nano cmdline.txt in terminal and got a blank page

Next you could boot from an micro SD card to increase the root partition on the HDD, and then create an ntfs partition on your PC. Sorry I do not understand this.

Sorry about all the questions but I am totally new at this but I am gradually learning bits and pieces.
It is difficult to write my answers in the quotes, for this reason I will copy the relevant sections below:

You can ignore the reference to Windows XP, this is not relevant in the process to create a bootable HDD for the Raspberry Pi as Windows 10 can also be used. It is important to know that there are two hard disks involved: your local, meaning internal disk on your computer and the external disk that will be used on the Pi.

The unzip utility is used to extract the image from the zip file to your local hard disk, this utility can extract files > 4GB from a zip file which is something Windows does not handle correctly.

I have given two methods that can be used, the first method uses a micro SD card and the second the external hard disk.
If you use the micro SD method then after booting the Pi with this card the root partition will be enlarged to fill the memory card. With Win32DiskImager you can create an image of the micro SD card on your internal hard disk, the image file can then be written with Win32DiskImager to your external hard disk. On this external disk you can use the Windows disk manager to create a new volume with NTFS. The Pi will mount this volume automatically in "/media/pi/<UUID>", but you can mount it in fstab somewhere else.

This is on a disk I created using a micro SD card:

Code: Select all

[email protected]:~ $ sudo blkid | grep sda
/dev/sda1: LABEL="boot" UUID="6228-7918" TYPE="vfat" PARTUUID="fd42fb14-01"
/dev/sda2: LABEL="rootfs" UUID="6bfc8851-cf63-4362-abf1-045dda421aad" TYPE="ext4" PARTUUID="fd42fb14-02"
/dev/sda3: LABEL="New Volume" UUID="AC4064D24064A534" TYPE="ntfs" PARTUUID="fd42fb14-03"
I created a directory "ntfs" in "/" for mounting and this is the contents of "/etc/fstab":

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=fd42fb14-01  /boot           vfat    defaults          0       2
PARTUUID=fd42fb14-02  /               ext4    defaults,noatime  0       1
PARTUUID=fd42fb14-03  /ntfs           ntfs    nofail,defaults   0       0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
The other method is similar except that the raspbian image is written directly to the external disk. Under Windows you can use notepad to edit "cmdline.txt" to remove the "init=..." entry which is at the root of the drive letter where the external disk is mounted. Next you can boot the Pi from a micro SD card without the external disk attached, after attaching the external hard disk you can use gparted to increase the size of the root partition. I can not give you instructions on how to do this, you will have to use google as there are many articles on this subject. Once done you can create the ntfs partition (volume) on your PC.

EDIT: Hold your horses, see next post
Last edited by Ernst on Fri Sep 21, 2018 11:15 am, edited 1 time in total.
The road to insanity is paved with static ip addresses

Ernst
Posts: 714
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 11:15 am

The following is how I installed Raspbian on a 1TB hard disk, with a 56GB ext4 partition for rootfs and the remainder for a partition with ntfs. Important: almost everything, except Win32DiskImager, can be/is done from the command line.

On your PC under Windows:
Download and install Win32DiskImager: https://sourceforge.net/projects/win32diskimager/
Download unzip from http://infozip.sourceforge.net/, place it somewhere in the search path.
Download raspbian stretch lite from: https://downloads.raspberrypi.org/raspbian_lite_latest
Use unzip from the command prompt to extract the image file from the zip file to the local hard disk
To conserve disk space you can delete the zip file from the local hard disk
Use Win32DiskImager to write the image file to a micro SD card
To conserve disk space you can delete the image file from the local hard disk
Boot your Pi using the micro SD card, if required configure with raspi-config, do not shutdown/power off.

Download raspbian stretch from: https://downloads.raspberrypi.org/raspbian_latest
Use unzip to extract the image file from the zip file to the local hard disk
To conserve disk space you can delete the zip file from the local hard disk
Use Win32DiskImager on your pc to write the image file the external hard disk
To conserve disk space you can delete the image file from the local hard disk

On your PC replug the hard disk, ignore any warnings (if any), note the drive letter assigned to the external hard disk
Use notepad to open the file "cmdline.txt" in the root directory of the drive letter assigned to the external hard disk
The contents of this file will be:

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=bd98648d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles
now remove "init=/usr/lib/raspi-config/init_resize.sh" so the line reads:

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=bd98648d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
If needed create an empty file named ssh (or ssh.txt) in the same directory as the "cmdline.txt" file, if required create a "wpa_supplicant.conf" file as well.

Unplug the external hard disk from your PC, plug the external disk into the Pi, make sure that the disk is recognized:

Code: Select all

[email protected]:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="3725-1C05" TYPE="vfat" PARTUUID="9117538d-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="fd695ef5-f047-44bd-b159-2a78c53af20a" TYPE="ext4" PARTUUID="9117538d-02"
/dev/mmcblk0: PTUUID="9117538d" PTTYPE="dos"
/dev/sda1: LABEL="boot" UUID="6228-7918" TYPE="vfat" PARTUUID="bd98648d-01"
/dev/sda2: LABEL="rootfs" UUID="6bfc8851-cf63-4362-abf1-045dda421aad" TYPE="ext4" PARTUUID="bd98648d-02"
Now use fdisk to increase the partition on the hard disk attached as /dev/sda2

Code: Select all

[email protected]:~ $ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 931.5 GiB, 1000170586112 bytes, 1953458176 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: 0xbd98648d

Device     Boot Start     End Sectors  Size Id Type
/dev/sda1        8192   96663   88472 43.2M  c W95 FAT32 (LBA)
/dev/sda2       98304 9420799 9322496  4.5G 83 Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

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

Created a new partition 2 of type 'Linux' and of size 56 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Next check that the partition has been increased in size

Code: Select all

[email protected]:~ $ sudo fdisk -l /dev/sda
Disk /dev/sda: 931.5 GiB, 1000170586112 bytes, 1953458176 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: 0xbd98648d

Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1        8192     96663     88472 43.2M  c W95 FAT32 (LBA)
/dev/sda2       98304 117538815 117440512   56G 83 Linux
And now fix the file system extension:

Code: Select all

[email protected]:~ $ sudo e2fsck -f /dev/sda2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootfs: 127794/291456 files (0.1% non-contiguous), 1043446/1165312 blocks
[email protected]:~ $ sudo resize2fs /dev/sda2
resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/sda2 to 14680064 (4k) blocks.
The filesystem on /dev/sda2 is now 14680064 (4k) blocks long.
Unplug the external disk from the Pi and plug into your PC
For the following you need administrator permissions.

Code: Select all


C:\> diskpart
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: FTH05W

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          476 GB  1024 KB
  Disk 1    Online         4657 GB      0 B        *
  Disk 2    Online         1397 GB      0 B
  Disk 3    Online         2794 GB      0 B        *
  Disk 4    No Media           0 B      0 B
  Disk 5    No Media           0 B      0 B
  Disk 6    No Media           0 B      0 B
  Disk 7    No Media           0 B      0 B
  Disk 8    No Media           0 B      0 B
  Disk 9    No Media           0 B      0 B
  Disk 10   No Media           0 B      0 B
  Disk 11   No Media           0 B      0 B
  Disk 12   Online          931 GB   875 GB

DISKPART> select disk 12

Disk 12 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary             43 MB  4096 KB
  Partition 2    Primary             56 GB    48 MB

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

DISKPART> select partition 3

Partition 3 is now the selected partition.

DISKPART> format fs=ntfs quick

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> assign

DiskPart successfully assigned the drive letter or mount point.

DISKPART> active

DiskPart marked the current partition as active.

DISKPART> exit

Remove the external disk from the PC, shutdown the Pi, remove power, remove the micro SD card, plug in the external disk, put power back into the Pi.
Wait, and I mean wait, for the desktop to be loaded, this can take a bit of time on the first boot from hard disk
Next open a terminal and install ntfs-3g to allow writing to the ntfs volume.

Code: Select all

sudo apt-get update
sudo apt-get install ntfs-3g
And you are ready to use the ntfs partition on the Pi.
The road to insanity is paved with static ip addresses

ejolson
Posts: 2159
Joined: Tue Mar 18, 2014 11:47 am

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 4:28 pm

Ernst wrote:
Fri Sep 21, 2018 11:15 am
The following is how I installed Raspbian on a 1TB hard disk, with a 56GB ext4 partition for rootfs and the remainder for a partition with ntfs.
Thanks for the write-up.

Am I right in supposing this method will work only for drives up to 2TB in size? My understanding is that fdisk doesn't handle larger disks and that Windows may do something strange when partitioning such a disk. I think a GPT type of partition table is required for larger disks, but the Pi won't recognize a boot partition in a GPT. Note that it might be possible to use a shadow partition table so the Pi still boots. I've not seen any discussion of this but maybe the person making the original post is using a 1TB drive anyway.

Ernst
Posts: 714
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 5:07 pm

ejolson wrote:
Fri Sep 21, 2018 4:28 pm
Ernst wrote:
Fri Sep 21, 2018 11:15 am
The following is how I installed Raspbian on a 1TB hard disk, with a 56GB ext4 partition for rootfs and the remainder for a partition with ntfs.
Thanks for the write-up.

Am I right in supposing this method will work only for drives up to 2TB in size? My understanding is that fdisk doesn't handle larger disks and that Windows may do something strange when partitioning such a disk. I think a GPT type of partition table is required for larger disks, but the Pi won't recognize a boot partition in a GPT. Note that it might be possible to use a shadow partition table so the Pi still boots. I've not seen any discussion of this but maybe the person making the original post is using a 1TB drive anyway.
imho you can be very right that the limit is 2TB because of GPT.
The road to insanity is paved with static ip addresses

epoch1970
Posts: 2126
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Move Pi home from SD card to a HDD

Fri Sep 21, 2018 6:05 pm

I think you can get away with the disk size and terrible extended partitions constraints by using a hybrid partition table, holding MBR and GPT at the same time.
https://superuser.com/questions/1181803 ... r-gpt-disc

Haven't tested it yet.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “General discussion”