<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Migration &amp;mdash; G&#39;s Blog</title>
    <link>https://blog.marcg.pizza/marcg/tag:Migration</link>
    <description>Just a place to post random things. Enjoy your stay.</description>
    <pubDate>Fri, 17 Apr 2026 01:08:54 -0300</pubDate>
    <item>
      <title>### NextCloud DB Migration to PostgreSQL (#100DaysToOffload Day 9)</title>
      <link>https://blog.marcg.pizza/marcg/nextcloud-db-migration-to-postgresql-100daystooffload-day-9</link>
      <description>&lt;![CDATA[### NextCloud DB Migration to PostgreSQL (#100DaysToOffload Day 9)&#xA;&#xA;So I&#39;m getting todays post out early because i have a feeling the rest of the day will get away from me. It&#39;s also going to be a quick one.&#xA;&#xA;(Late)Last night i decided to finally migrate my Nextcloud server&#39;s DB to PostgreSQL from Mysql. No specific reason other than I&#39;ve heard many times that PostgreSQL performs/scales better. I&#39;ve been wanting to do it for a while but figured it would be a long dangerous process that would almost require a reinstall of the server. Thanks to a toot on mastodon i found out that Nextcloud has an easy tool to do the migration. So after doing regular updates on the server i decided to do the migration. Seemed simply enough. Just run the following:&#xA;&#xA;occ db:convert-type --all-apps pgsql nextcloud 127.0.0.1 nextcloud&#xA;&#xA;That ended badly&#xA;&#xA;It was so late when i was doing this and i was very tired. The install was not broken so i just turned off maintenance mode and went to bed with the idea that i would spend much time this morning figuring out what was going wrong and how to fix it. I quickly posted to the Nextcloud IRC chan before i went to bed.&#xA;&#xA;There was no response when i got up. I had a closer look at the error message and realized it was referring to a specific app. One that i had installed but never actually used. The Following ococdownloaderqueueIDseq pointed me in that direction. So i disabled/removed that app(oc Downloader) and deleted the 3 related tables from Mysql DB then re-ran the migration as follows:&#xA;&#xA;occ db:convert-type --clear-schema --all-apps pgsql nextcloud 127.0.0.1 nextcloud&#xA;&#xA;Had to add the --clear-schema option since the schema had already been created in the PostgreSQL DB. All went well this time. For good measure i ran&#xA;occ maintenance:repair that also went well.&#xA;&#xA;Turned off maintenance mode and opened up the app. I right away noticed that things where loading faster. I navigated over to the admin overview page and it had a few recommendations. Had to run the following:&#xA;&#xA;occ db:add-missing-indices&#xA;&#xA;This could be done without enabling maintenance mode. Also had to run:&#xA;&#xA;occ db:convert-filecache-bigint&#xA;&#xA;This one had to be done while in maintenance mode.&#xA;&#xA;After that all was happy. I was able to reinstall the offending app. I actually set it up this time and might actually put it to use.&#xA;&#xA;I must say that things do seem to load faster(placebo or not). Overall a great migration. I&#39;m not sure why NextCloud officially recommends Mysql over PostgreSQL but i would recommend to use PostgreSQL.&#xA;&#xA;The only thing on that server left using Mysql is this blog(Writefreely). I&#39;m going to see if that can use PostgreSQL as well. That way i can have only one DB backend running.&#xA;&#xA;That is all for today(Ok maybe not a quick one after all).&#xA;&#xA;Until tomorrow be safe!&#xA;&#xA;@mgrondin@youdabomb.social&#xA;&#xA;#Tech #Migration #Nextcloud&#xA;&#xA;Until next time. Stay safe!&#xD;&#xA;&#xD;&#xA;G&#xD;&#xA;@mgrondin@youdabomb.social]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="nextcloud-db-migration-to-postgresql-100daystooffload-day-9">NextCloud DB Migration to PostgreSQL (<a href="/marcg/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a> Day 9)</h3>

<p>So I&#39;m getting todays post out early because i have a feeling the rest of the day will get away from me. It&#39;s also going to be a quick one.</p>

<p>(Late)Last night i decided to finally migrate my Nextcloud server&#39;s DB to PostgreSQL from Mysql. No specific reason other than I&#39;ve heard many times that PostgreSQL performs/scales better. I&#39;ve been wanting to do it for a while but figured it would be a long dangerous process that would almost require a reinstall of the server. Thanks to a toot on mastodon i found out that Nextcloud has an easy tool to do the migration. So after doing regular updates on the server i decided to do the migration. Seemed simply enough. Just run the following:</p>

<p><code>occ db:convert-type --all-apps pgsql nextcloud 127.0.0.1 nextcloud</code></p>

<p>That ended <a href="https://paste.marcg.pizza/~marcg/218132b61e0724f75b68c470af72e61b9ce40b11" rel="nofollow">badly</a></p>

<p>It was so late when i was doing this and i was very tired. The install was not broken so i just turned off maintenance mode and went to bed with the idea that i would spend much time this morning figuring out what was going wrong and how to fix it. I quickly posted to the Nextcloud IRC chan before i went to bed.</p>

<p>There was no response when i got up. I had a closer look at the error message and realized it was referring to a specific app. One that i had installed but never actually used. The Following <code>oc_ocdownloader_queue_ID_seq</code> pointed me in that direction. So i disabled/removed that app(oc Downloader) and deleted the 3 related tables from Mysql DB then re-ran the migration as follows:</p>

<pre><code>occ db:convert-type --clear-schema --all-apps pgsql nextcloud 127.0.0.1 nextcloud
</code></pre>

<p>Had to add the <code>--clear-schema</code> option since the schema had already been created in the PostgreSQL DB. All went well this time. For good measure i ran
<code>occ maintenance:repair</code> that also went well.</p>

<p>Turned off maintenance mode and opened up the app. I right away noticed that things where loading faster. I navigated over to the admin overview page and it had a few recommendations. Had to run the following:</p>

<p><code>occ db:add-missing-indices</code></p>

<p>This could be done without enabling maintenance mode. Also had to run:</p>

<p><code>occ db:convert-filecache-bigint</code></p>

<p>This one had to be done while in maintenance mode.</p>

<p>After that all was happy. I was able to reinstall the offending app. I actually set it up this time and might actually put it to use.</p>

<p>I must say that things do seem to load faster(placebo or not). Overall a great migration. I&#39;m not sure why NextCloud officially recommends Mysql over PostgreSQL but i would recommend to use PostgreSQL.</p>

<p>The only thing on that server left using Mysql is this blog(Writefreely). I&#39;m going to see if that can use PostgreSQL as well. That way i can have only one DB backend running.</p>

<p>That is all for today(Ok maybe not a quick one after all).</p>

<p>Until tomorrow be safe!</p>

<p><a href="https://blog.marcg.pizza/@/mgrondin@youdabomb.social" class="u-url mention" rel="nofollow">@<span>mgrondin@youdabomb.social</span></a></p>

<p><a href="/marcg/tag:Tech" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Tech</span></a> <a href="/marcg/tag:Migration" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Migration</span></a> <a href="/marcg/tag:Nextcloud" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Nextcloud</span></a></p>

<p>Until next time. Stay safe!</p>

<p>G
<a href="https://blog.marcg.pizza/@/mgrondin@youdabomb.social" class="u-url mention" rel="nofollow">@<span>mgrondin@youdabomb.social</span></a></p>
]]></content:encoded>
      <guid>https://blog.marcg.pizza/marcg/nextcloud-db-migration-to-postgresql-100daystooffload-day-9</guid>
      <pubDate>Sun, 03 May 2020 09:05:05 -0300</pubDate>
    </item>
    <item>
      <title>Hello Everyone</title>
      <link>https://blog.marcg.pizza/marcg/hello-everyone</link>
      <description>&lt;![CDATA[Hello Everyone&#xA;&#xA;I have decided to migrate my blog from using Github Pages to self hosting it using WriteFreely. If all goes well i&#39;ll be able to boost this on Mastodon.&#xA;&#xA;I will still post sporadically when I have time and something worth sharing.&#xA;&#xA;I will also be migrating my old posts at some point. Probably over the weekend.&#xA;&#xA;That&#39;s all for now.&#xA;&#xA;Have a great day.&#xA;&#xA;G&#xA;&#xA;#Tech #Meta #SelfHost #Migration&#xA;&#xA;Until next time. Stay safe!&#xD;&#xA;&#xD;&#xA;G&#xD;&#xA;@mgrondin@youdabomb.social]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="hello-everyone">Hello Everyone</h3>

<p>I have decided to migrate my blog from using <a href="https://pages.github.com/" rel="nofollow">Github Pages</a> to self hosting it using WriteFreely. If all goes well i&#39;ll be able to boost this on Mastodon.</p>

<p>I will still post sporadically when I have time and something worth sharing.</p>

<p>I will also be migrating my old posts at some point. Probably over the weekend.</p>

<p>That&#39;s all for now.</p>

<p>Have a great day.</p>

<p>G</p>

<p><a href="/marcg/tag:Tech" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Tech</span></a> <a href="/marcg/tag:Meta" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Meta</span></a> <a href="/marcg/tag:SelfHost" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">SelfHost</span></a> <a href="/marcg/tag:Migration" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Migration</span></a></p>

<p>Until next time. Stay safe!</p>

<p>G
<a href="https://blog.marcg.pizza/@/mgrondin@youdabomb.social" class="u-url mention" rel="nofollow">@<span>mgrondin@youdabomb.social</span></a></p>
]]></content:encoded>
      <guid>https://blog.marcg.pizza/marcg/hello-everyone</guid>
      <pubDate>Thu, 23 Jan 2020 21:48:09 -0400</pubDate>
    </item>
    <item>
      <title>NextCloud Migration(Again)</title>
      <link>https://blog.marcg.pizza/marcg/nextcloud-migration-again</link>
      <description>&lt;![CDATA[NextCloud Migration(Again)&#xA;&#xA;So this post will detail the steps I took to migrate my Nextcloud instance from my old VPS(Named Zeus) to my new bigger VPS(Named Hera). When I got Zeus I was not really planing on moving my Nextcloud instance to it but once I decided to keep Zeus I did just that.&#xA;&#xA;After moving Nextcloud I also decided to host a Peertube instance. I quickly realized that with both of those on it I would outgrow the storage on Zeus so I got the next level VPS offered by the hosting company I went with.&#xA;&#xA;And so now I have to migrate again. So lets get on with it.&#xA;&#xA;I will not cover the initial setup required since I assume that if you are in need of a migration guide you already have nextcloud setup. Arch linux has a good guide if you need one. Also to note I run Arch linux so some of these steps/paths will be specific to Arch but the steps should give you an understanding of what needs to happen.&#xA;&#xA;On to the migration. As I said the first step was to perform inital setup and installation of dependencies on Hera. Once that was done the real fun begins.&#xA;&#xA;First we must place the nextcloud instance on Zeus in maintenance mode so that no new files/changes are made while we copy things over to Hera. This is done simply by issuing this command from the root of the nextcloud install.&#xA;&#xA;sudo -u http ./occ maintenance:mode --on&#xA;&#xA;Note that if on your distro the root of the nextcloud install is not owned by the http user you will need to adjust that in the command above.&#xA;&#xA;After this command you should wait around 10 minutes to ensure all clients have received the maintenance notification and have stoped syncing. In my case that&#39;s just my couple of PC&#39;s and my phone but still best to give it this time. Then we stop our http server.&#xA;&#xA;The next step is to copy the nextcloud application folder from Zeus to Hera. This can be done using rsync initiated from Zeus:&#xA;&#xA;rsync -Aavx /usr/sahre/webapps/nextcloud/ root@hera.gcfam.net:/usr/share/webapps/nextcloud&#xA;&#x9;&#xA;This ensures that all apps installed on your instance are also copied over.&#xA;&#x9;&#xA;Once this is done we copy the nextcloud config. Again using rsync and initiated from Zeus:&#xA;&#xA;rsync -Aavx /etc/webapps/nextcloud/config/ root@hera.gcfam.net:/etc/webapps/nextcloud/config&#xA;&#x9;&#xA;Using the same command we should also copy the webserver config,ssl certificate and webserver logs related to nextcloud.&#xA;&#x9;&#xA;Next we create a dump of the nextcloud database on Zeus. In my case I&#39;m using mysql so the command is&#xA;&#xA;mysqldump --single-transaction -h localhost -u root -p nextcloud   nextcloud-sqlbkpdate +&#34;%Y%m%d&#34;.bak&#xA;&#x9;&#xA;This will create nextcloud-sqlbkp20191111.bak. Then we can use rsync to copy this dump to Hera&#xA;&#xA;rsync -Aavx nextcloud-sqlbkp20191111.bak root@hera.gcfam.net:/root&#xA;&#x9;&#xA;Now we restore the dump on Hera&#xA;&#xA;mysql -h localhost -u root -p nextcloud &lt; nextcloud-sqlbkp20191111.bak&#xA;&#x9;&#xA;Finally we copy the data folder from Zeus to Hera. This is once again done with rsync this time we add the -t option so it preserves timestamps otherwise all files will need to be re-downloaded by clients&#xA;&#xA;rsync -Aavxt /srv/CloudData/ root@hera.gcfam.net:/srv/CloudData&#xA;&#x9;&#xA;Obviously depending on the amount of data stored on your instance and the connection speed between the two servers this could take a while.&#xA;&#xA;Once this is completed we should be able to start the webserver on Hera.&#xA;&#xA;With that started we should be able to access nextcloud using the IP address of Hera. We do this before changing the DNS entry incase something does not work. If we get the maintenance mode warning then we should be golden.&#xA;&#xA;We can now disable maintenance on Hera&#xA;&#xA;sudo -u http ./occ maintenance:mode --off&#xA;&#x9;&#xA;Now we can confirm that we are able to login and if everything seems to work. After that we can update the DNS entry and our migration has been a sucess!!&#xA;&#xA;Have a great day.&#xA;&#xA;G&#xA;&#xA;#Tech #Migration #Nextcloud&#xA;&#xA;Until next time. Stay safe!&#xD;&#xA;&#xD;&#xA;G&#xD;&#xA;@mgrondin@youdabomb.social]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="nextcloud-migration-again">NextCloud Migration(Again)</h3>

<p>So this post will detail the steps I took to migrate my Nextcloud instance from my old VPS(Named Zeus) to my new bigger VPS(Named Hera). When I got Zeus I was not really planing on moving my Nextcloud instance to it but once I decided to keep Zeus I did just that.</p>

<p>After moving Nextcloud I also decided to host a Peertube instance. I quickly realized that with both of those on it I would outgrow the storage on Zeus so I got the next level VPS offered by the hosting company I went with.</p>

<p>And so now I have to migrate again. So lets get on with it.</p>

<p>I will not cover the initial setup required since I assume that if you are in need of a migration guide you already have nextcloud setup. Arch linux has a <a href="https://wiki.archlinux.org/index.php/Nextcloud" rel="nofollow">good guide</a> if you need one. Also to note I run Arch linux so some of these steps/paths will be specific to Arch but the steps should give you an understanding of what needs to happen.</p>

<p>On to the migration. As I said the first step was to perform inital setup and installation of dependencies on Hera. Once that was done the real fun begins.</p>

<p>First we must place the nextcloud instance on Zeus in maintenance mode so that no new files/changes are made while we copy things over to Hera. This is done simply by issuing this command from the root of the nextcloud install.</p>

<p><code>sudo -u http ./occ maintenance:mode --on</code></p>

<p>Note that if on your distro the root of the nextcloud install is not owned by the http user you will need to adjust that in the command above.</p>

<p>After this command you should wait around 10 minutes to ensure all clients have received the maintenance notification and have stoped syncing. In my case that&#39;s just my couple of PC&#39;s and my phone but still best to give it this time. Then we stop our http server.</p>

<p>The next step is to copy the nextcloud application folder from Zeus to Hera. This can be done using rsync initiated from Zeus:</p>

<pre><code>rsync -Aavx /usr/sahre/webapps/nextcloud/ root@hera.gcfam.net:/usr/share/webapps/nextcloud
</code></pre>

<p>This ensures that all apps installed on your instance are also copied over.</p>

<p>Once this is done we copy the nextcloud config. Again using rsync and initiated from Zeus:</p>

<pre><code>rsync -Aavx /etc/webapps/nextcloud/config/ root@hera.gcfam.net:/etc/webapps/nextcloud/config
</code></pre>

<p>Using the same command we should also copy the webserver config,ssl certificate and webserver logs related to nextcloud.</p>

<p>Next we create a dump of the nextcloud database on Zeus. In my case I&#39;m using mysql so the command is</p>

<pre><code>mysqldump --single-transaction -h localhost -u root -p nextcloud &gt; nextcloud-sqlbkp_`date +&#34;%Y%m%d&#34;`.bak
</code></pre>

<p>This will create <code>nextcloud-sqlbkp_20191111.bak</code>. Then we can use rsync to copy this dump to Hera</p>

<p><code>rsync -Aavx nextcloud-sqlbkp_20191111.bak root@hera.gcfam.net:/root</code></p>

<p>Now we restore the dump on Hera</p>

<pre><code>mysql -h localhost -u root -p nextcloud &lt; nextcloud-sqlbkp_20191111.bak
</code></pre>

<p>Finally we copy the data folder from Zeus to Hera. This is once again done with rsync this time we add the -t option so it preserves timestamps otherwise all files will need to be re-downloaded by clients</p>

<p><code>rsync -Aavxt /srv/CloudData/ root@hera.gcfam.net:/srv/CloudData</code></p>

<p>Obviously depending on the amount of data stored on your instance and the connection speed between the two servers this could take a while.</p>

<p>Once this is completed we should be able to start the webserver on Hera.</p>

<p>With that started we should be able to access nextcloud using the IP address of Hera. We do this before changing the DNS entry incase something does not work. If we get the maintenance mode warning then we should be golden.</p>

<p>We can now disable maintenance on Hera</p>

<p><code>sudo -u http ./occ maintenance:mode --off</code></p>

<p>Now we can confirm that we are able to login and if everything seems to work. After that we can update the DNS entry and our migration has been a sucess!!</p>

<p>Have a great day.</p>

<p>G</p>

<p><a href="/marcg/tag:Tech" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Tech</span></a> <a href="/marcg/tag:Migration" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Migration</span></a> <a href="/marcg/tag:Nextcloud" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Nextcloud</span></a></p>

<p>Until next time. Stay safe!</p>

<p>G
<a href="https://blog.marcg.pizza/@/mgrondin@youdabomb.social" class="u-url mention" rel="nofollow">@<span>mgrondin@youdabomb.social</span></a></p>
]]></content:encoded>
      <guid>https://blog.marcg.pizza/marcg/nextcloud-migration-again</guid>
      <pubDate>Mon, 11 Nov 2019 13:03:22 -0400</pubDate>
    </item>
    <item>
      <title>Migrate all the things!!</title>
      <link>https://blog.marcg.pizza/marcg/migrate-all-the-things</link>
      <description>&lt;![CDATA[Migrate all the things!!&#xA;&#xA;As i stated in my previous post my primary harddrive is failing on me. To be proactive i am replacing it before it fully dies. &#xA;&#xA;So this will be a somewhat technical post where I will outline the steps I took to migrate to my new HDD. Some of these steps will be specific to my setup but most could be applied to other situations. Hope you find some of this useful or at least informational.&#xA;&#xA;First some details on the setup. I use BTRFS as my filesystem on all my drives. BTRFS provides a subvolume functionality. Subvolumes are similar to partitions in which they can be mounted/accessed independently from the main/root of the filesystem. So my old drive was setup with the following subvolumes:&#xA;&#x9;&#xA;table border=&#34;1&#34;&#xA;thSubvolume/th&#xA;thDescription/th&#xA;tr&#xA;td@Home/td&#xA;tdThis contains my Home partition/td&#xA;/tr&#xA;tr&#xA;td@Storage/td&#xA;tdThis contains my primary storage (Hold Downloads,Wallpapers and other general data)/td&#xA;/tr&#xA;tr&#xA;td@HomestBU/td&#xA;td This was used to make backups(More will be explained on how to handle backups with BTRFS subvolumes/snapshots)/td&#xA;/tr&#xA;/table&#xA;&#xA;This same layout will be replicated on the new drive later.&#xA;&#xA;To avoid any data loss I had moved my @Home subvolume to my raid5 array(Called Storage2) which typically holds my media files and my @Storage subvolume to my external storage device(called Storage3) that normally holds my backups. Now the task will be to move those subvolumes to the new harddrive. So lets get on with it.&#xA;&#xA;This is the drive I am migrating stuff to&#xA;&#xA;HarddriveImagegoeshere&#xA;&#xA;Lets begin the migration.&#xA;&#xA;Since I have all my storage encrypted the first step is to setup the encryption container. This is done by issuing the following cammand:&#xA;&#x9;&#xA;cryptsetup -v --type luks --cipher anubis-xts-plain64 --keysize 640 --hash whirlpool --iter-time 5000 --use-random -d /etc/homest luksFormat&#xA;&#x9;&#xA;Lets breakdown that command a bit shall we&#xA;&#xA;table&#xA;thOption/th&#xA;thDesctiption/th&#xA;tr&#xA;td-v/td&#xA;tdThis simply makes the cryptsetup command output mor detailed information about what it does/td&#xA;/tr&#xA;tr&#xA;td --type luks/td&#xA;tdThis instructs cryptsetup that we are working in luks mode instead of plain mode (See a href=&#34;https://www.linode.com/docs/security/encrypt-data-disk-with-dm-crypt/#dm-crypt-in-plain-mode-vs-dm-crypt-with-luks-extension&#34; target=&#34;blank&#34;here/a for an explanation of the differences between plain and luks mode.)/td&#xA;/tr&#xA;tr&#xA;td--cipher anubis-xts-plain64/td&#xA;tdThis is defining the cipher to be used for the encryption operation. I always use a cipher that is not as mainstream. In this case i am using the anubis cipher. I like this cipher for a few reasons. One of them being that it is named after an egyptian god and the creator has stated that anyone who breaks it will be cursed./td&#xA;/tr&#xA;tr&#xA;td--keysize 640/td&#xA;tdThis defines the size(in bits) of the key used for encryption. The bigger the key the stronger the encryption. Anubix has a maximum key size of 320 but since the xtx cipher mode splits the key in 2 we specify 640 here./td&#xA;/tr&#xA;tr&#xA;td--hash whirlpool/td&#xA;tdThis defines what hash function(default sha256) will be used the hash the passphrase./td&#xA;/tr&#xA;tr&#xA;td--iter-time 5000/td&#xA;tdThis defines how long(in miliseconds) cryptsetup will spend processing the keyphrase. Default is 1 second I make it go for 5./td&#xA;/tr&#xA;tr&#xA;td--use-random/td&#xA;tdThis define the source used for the generation of random numbers used by the format process. Choices are urandom or random. I always use random as it produces a more random result/td&#xA;/tr&#xA;tr&#xA;td-d /etc/homest/td&#xA;tdThis defines a keyfile to use instead of prompting for a passphrase. That key file is a giant string of random characters/td&#xA;/tr&#xA;tr&#xA;tdluksFormat/td&#xA;tdThis just says to format the device that follows/td&#xA;/tr&#xA;tr&#xA;td/dev/sdxY/td&#xA;tdThe device to format/td&#xA;/tr&#xA;/table&#xA;&#xA;Now that the encrypted container is ready we can open it to use it:&#xA;&#x9;&#xA;cryptsetup open -d /etc/homest /dev/sdxY homest&#xA;&#x9;&#xA;&#xA;Now we can format the container with a filesystem:&#xA;&#x9;&#xA;mkfs.btrfs /dev/mapper/homest&#xA;&#x9;&#xA;And mount it:&#xA;&#x9;&#xA;fstab entry&#xA;/dev/mapper/homest                              /mnt/btrfsroot           btrfs           compress=zlib,spacecache=v2       0 0&#xA;&#x9;&#xA;mount /mnt/btrfsroot&#xA;&#x9;&#xA;&#xA;Starting with my @Storage subvolume we will now move it to the new drive&#xA;&#xA;First we create a read-only snapshot of the subvolume:&#xA;&#x9;&#xA;btrfs subvol snap -r \@Storage/ \@Storage.migrate&#xA;&#x9;&#xA;A snapshot is like a picture of the data currently in that subvolume.&#xA;&#xA;Now we send it over to the new drive:&#xA;&#x9;&#xA;btrfs send -vvv \@Storage.migrate/ | btrfs receive -vvv /mnt/btrfsroot/&#xA;&#x9;&#xA;&#xA;Once this is complete we update the fstab entry to mount the subvolume from it&#39;s new location:&#xA;&#xA;/dev/mapper/homest                              /media/Storage  btrfs           compress=zlib,spacecache=v2,subvol=@Storage    0 0&#xA;&#x9;&#xA;Notice how this entry is similar to the previouse with the differences being the mountpoint(/media/Storage) and that we specify the subvolume to mount.&#xA;&#xA;Now we do the same thing with the @Home subvolume.&#xA;&#xA;First we create a read-only snapshot of the subvolume:&#xA;&#x9;&#xA;btrfs subvol snap -r \@Home/ \@Home.migrate&#xA;&#x9;&#xA;&#xA;Now we send it over to the new drive:&#xA;&#x9;&#xA;btrfs send -vvv \@Home.migrate/ | btrfs receive -vvv /mnt/btrfsroot/&#xA;&#x9;&#xA;&#xA;Once this is complete we update the fstab entry to mount the subvolume from it&#39;s new location:&#xA;/dev/mapper/homest                              /Home  btrfs           compress=zlib,space_cache=v2,subvol=@Home    0 0&#xA;&#x9;&#xA;Now the subvolumes on the receive side(now in /mnt/btrfsroot) are still in read-only mode which wont work. To resolve that we simply take a read-write snapshot of the subvolume:&#xA;&#x9;&#xA;btrfs subvol snap \@Home.migrate \@Home&#xA;btrfs subvol snap \@Storage.migrate \@Storage&#xA;&#xA;And That is it. Migration complete. All that is left to do is reboot to start using the new drive. Hope you maybe found this post informational.&#xA;&#xA;Have a great day.&#xA;&#xA;G&#xA;&#xA;#Tech #Migration #Linux #BTRFS&#xA;&#xA;Until next time. Stay safe!&#xD;&#xA;&#xD;&#xA;G&#xD;&#xA;@mgrondin@youdabomb.social]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="migrate-all-the-things">Migrate all the things!!</h3>

<p>As i stated in my previous post my primary harddrive is failing on me. To be proactive i am replacing it before it fully dies.</p>

<p>So this will be a somewhat technical post where I will outline the steps I took to migrate to my new HDD. Some of these steps will be specific to my setup but most could be applied to other situations. Hope you find some of this useful or at least informational.</p>

<p>First some details on the setup. I use BTRFS as my filesystem on all my drives. BTRFS provides a subvolume functionality. Subvolumes are similar to partitions in which they can be mounted/accessed independently from the main/root of the filesystem. So my old drive was setup with the following subvolumes:</p>

<table>
<th>Subvolume</th>
<th>Description</th>
<tr>
<td>@Home</td>
<td>This contains my Home partition</td>
</tr>
<tr>
<td>@Storage</td>
<td>This contains my primary storage (Hold Downloads,Wallpapers and other general data)</td>
</tr>
<tr>
<td>@HomestBU</td>
<td> This was used to make backups(More will be explained on how to handle backups with BTRFS subvolumes/snapshots)</td>
</tr>
</table>

<p>This same layout will be replicated on the new drive later.</p>

<p>To avoid any data loss I had moved my @Home subvolume to my raid5 array(Called Storage2) which typically holds my media files and my @Storage subvolume to my external storage device(called Storage3) that normally holds my backups. Now the task will be to move those subvolumes to the new harddrive. So lets get on with it.</p>

<p>This is the drive I am migrating stuff to</p>

<p><img src="/img/postimages/newdrive.png" alt="Harddrive_Image_goes_here"></p>

<p>Lets begin the migration.</p>

<p>Since I have all my storage encrypted the first step is to setup the encryption container. This is done by issuing the following cammand:</p>

<pre><code>cryptsetup -v --type luks --cipher anubis-xts-plain64 --keysize 640 --hash whirlpool --iter-time 5000 --use-random -d /etc/homest luksFormat
</code></pre>

<p>Lets breakdown that command a bit shall we</p>

<table>
<th>Option</th>
<th>Desctiption</th>
<tr>
<td>-v</td>
<td>This simply makes the cryptsetup command output mor detailed information about what it does</td>
</tr>
<tr>
<td> --type luks</td>
<td>This instructs cryptsetup that we are working in luks mode instead of plain mode (See <a href="https://www.linode.com/docs/security/encrypt-data-disk-with-dm-crypt/#dm-crypt-in-plain-mode-vs-dm-crypt-with-luks-extension" target="_blank" rel="nofollow noopener">here</a> for an explanation of the differences between plain and luks mode.)</td>
</tr>
<tr>
<td>--cipher anubis-xts-plain64</td>
<td>This is defining the cipher to be used for the encryption operation. I always use a cipher that is not as mainstream. In this case i am using the anubis cipher. I like this cipher for a few reasons. One of them being that it is named after an egyptian god and the creator has stated that anyone who breaks it will be cursed.</td>
</tr>
<tr>
<td>--keysize 640</td>
<td>This defines the size(in bits) of the key used for encryption. The bigger the key the stronger the encryption. Anubix has a maximum key size of 320 but since the xtx cipher mode splits the key in 2 we specify 640 here.</td>
</tr>
<tr>
<td>--hash whirlpool</td>
<td>This defines what hash function(default sha256) will be used the hash the passphrase.</td>
</tr>
<tr>
<td>--iter-time 5000</td>
<td>This defines how long(in miliseconds) cryptsetup will spend processing the keyphrase. Default is 1 second I make it go for 5.</td>
</tr>
<tr>
<td>--use-random</td>
<td>This define the source used for the generation of random numbers used by the format process. Choices are urandom or random. I always use random as it produces a more random result</td>
</tr>
<tr>
<td>-d /etc/homest</td>
<td>This defines a keyfile to use instead of prompting for a passphrase. That key file is a giant string of random characters</td>
</tr>
<tr>
<td>luksFormat</td>
<td>This just says to format the device that follows</td>
</tr>
<tr>
<td>/dev/sdxY</td>
<td>The device to format</td>
</tr>
</table>

<p>Now that the encrypted container is ready we can open it to use it:</p>

<p><code>cryptsetup open -d /etc/homest /dev/sdxY homest</code></p>

<p>Now we can format the container with a filesystem:</p>

<p><code>mkfs.btrfs /dev/mapper/homest</code></p>

<p>And mount it:</p>

<p>fstab entry</p>

<pre><code>/dev/mapper/homest                              /mnt/btrfsroot           btrfs           compress=zlib,space_cache=v2       0 0
</code></pre>

<p><code>mount /mnt/btrfsroot</code></p>

<p>Starting with my @Storage subvolume we will now move it to the new drive</p>

<p>First we create a read-only snapshot of the subvolume:</p>

<p><code>btrfs subvol snap -r \@Storage/ \@Storage.migrate</code></p>

<p>A snapshot is like a picture of the data currently in that subvolume.</p>

<p>Now we send it over to the new drive:</p>

<p><code>btrfs send -vvv \@Storage.migrate/ | btrfs receive -vvv /mnt/btrfsroot/</code></p>

<p>Once this is complete we update the fstab entry to mount the subvolume from it&#39;s new location:</p>

<pre><code>/dev/mapper/homest                              /media/Storage  btrfs           compress=zlib,space_cache=v2,subvol=@Storage    0 0
</code></pre>

<p>Notice how this entry is similar to the previouse with the differences being the mountpoint(/media/Storage) and that we specify the subvolume to mount.</p>

<p>Now we do the same thing with the @Home subvolume.</p>

<p>First we create a read-only snapshot of the subvolume:</p>

<p><code>btrfs subvol snap -r \@Home/ \@Home.migrate</code></p>

<p>Now we send it over to the new drive:</p>

<p><code>btrfs send -vvv \@Home.migrate/ | btrfs receive -vvv /mnt/btrfsroot/</code></p>

<p>Once this is complete we update the fstab entry to mount the subvolume from it&#39;s new location:</p>

<pre><code>/dev/mapper/homest                              /Home  btrfs           compress=zlib,space_cache=v2,subvol=@Home    0 0
</code></pre>

<p>Now the subvolumes on the receive side(now in /mnt/btrfsroot) are still in read-only mode which wont work. To resolve that we simply take a read-write snapshot of the subvolume:</p>

<p><code>btrfs subvol snap \@Home.migrate \@Home</code>
<code>btrfs subvol snap \@Storage.migrate \@Storage</code></p>

<p>And That is it. Migration complete. All that is left to do is reboot to start using the new drive. Hope you maybe found this post informational.</p>

<p>Have a great day.</p>

<p>G</p>

<p><a href="/marcg/tag:Tech" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Tech</span></a> <a href="/marcg/tag:Migration" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Migration</span></a> <a href="/marcg/tag:Linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Linux</span></a> <a href="/marcg/tag:BTRFS" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BTRFS</span></a></p>

<p>Until next time. Stay safe!</p>

<p>G
<a href="https://blog.marcg.pizza/@/mgrondin@youdabomb.social" class="u-url mention" rel="nofollow">@<span>mgrondin@youdabomb.social</span></a></p>
]]></content:encoded>
      <guid>https://blog.marcg.pizza/marcg/migrate-all-the-things</guid>
      <pubDate>Mon, 31 Dec 2018 05:51:45 -0400</pubDate>
    </item>
  </channel>
</rss>